How to create a condition that does not include the month of December?

3

I'm creating a condition to be run before the month of December, that is, it only runs in the January period of November .

IF (SELECT TarFechamento FROM Tarefa WHERE TarID = @Tarefa) < '01-12-2017'

I put it like it was in the year of 2017 , but I want independent of the year 2018,2019,2020, etc.     

asked by anonymous 17.10.2017 / 19:06

2 answers

4

The query you need to do is this, using month ( ) to know only the month of the date

SELECT * FROM Tarefa WHERE TarID = @Tarefa and month(TarFechamento) <> 12
    
17.10.2017 / 19:11
0

The easiest way to get (not) just the part of the month from a date in SQL is to just use the DATEPART () function. For more information about the function, just visit the link link.

    
19.02.2018 / 14:02