Doubt - Query SQL Server 2012

0

Good morning!

I have a query below that I need to bring inside the case only when the TarVencimento is smaller than today's date (so far I have been able to do it), but only when today's date is until the 5th day after the date of maturity. Example: A task number 11111 was due on 11/11/2017 and today is 11/22/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 Task T

    
asked by anonymous 22.11.2017 / 12:20

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 T Task

    
22.11.2017 / 12:32