Skip to content
Advertisement

SQL check whether current date is monday

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
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement