Skip to content
Advertisement

How to exclude between a particular date range each year in SQL

I’m trying to exclude the Christmas period between two dates every year in my database. This is the query I’m trying to run. From my understanding this should include every row, for every year with the exception of rows where the month is <= 12 and day <= 15 and where the month is <= 12 and day >= 26.

The result, however, doesn’t appear to return any rows at all!

Does anyone have any suggestions as to how to filter out Dec-15 to Dec-26 each year here?

Advertisement

Answer

You should specify your DBMS, because the following code can change. Please provide it and I will glade to update my answer.

For something quick and if I understand your logic:

You can reverse the query if you put NOT after the WHERE

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement