I am trying to create a SQL statement in where clause so when the current date is a Monday, it returns Friday results, but if it is any other weekday, it returns yesterday as the result.
Something like this:
WHERE ---IS MONDAY ? ---THEN DATE = 'FRIDAY' ---IS TUESDAY,WEDNESDAY, THURSDAY OR FRIDAY ? ---THEN DATE = 'YESTERDAY'
How can I accomplish that using IIF or CASE?
Advertisement
Answer
In Firebird, you can use EXTRACT()
:
WHERE EXTRACT(WEEKDAY FROM my_date) = 1