Home > Enterprise >  Exclude 1 Year from a date range
Exclude 1 Year from a date range

Time:12-06

I would like to exclude the year 2020 from my column the_date_transaction which is a timestamp. I have written this but it returns 'Query returned no results':

WHERE to_date(tdt.the_date_transaction) BETWEEN '2019-01-01' AND '2019-12-31' AND to_date(tdt.the_date_transaction) BETWEEN '2021-01-01' AND '2022-11-31'

I have searched on stackoverflow but no luck, can someone please help me ?

CodePudding user response:

You should use NOT BETWEEN instead:

SELECT ...
FROM ...
WHERE to_date(tdt.the_date_transaction) NOT BETWEEN '2020-01-01' AND '2020-12-31'
  • Related