Doubt - Query SQL Server 2012

Asked

Viewed 39 times

0

I have a query below that I need to bring inside the case only when the field Tarvencimento is less than today’s date (so far I managed to do), however, only when today’s date is 5° day after the expiration date.
Example: A task number 11111 was won on 10/11/2017 and today is 22/11/2017 so it was not to bring this task, it was only to bring today’s date from 11/11 to 15/11.

SELECT 
    CASE WHEN  T.TarVencimento < getdate() THEN CAST(datediff(day,TarVencimento,getdate()) AS VARCHAR) ELSE '0' END +' (TEMPO)'
    FROM Tarefa T

1 answer

0


See if that’s it

SELECT 
    CASE WHEN dateadd(day, 5, T.TarVencimento) < getdate() THEN  
         CAST(datediff(day, TarVencimento, getdate()) AS VARCHAR) 
    ELSE '0' END +' (TEMPO)'
FROM Tarefa T
  • That way it didn’t work @Will Palaro.

  • What does it take? It was a mistake? It’s bringing more or less day?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.