Skip to content
Advertisement

ODBC – Exclude weekends in SQL

I currently have this SELECT statement which allows me to get yesterday’s date:

However, when the day is Monday, I need the result to return a value date for Friday and not Sunday. When the day is Tuesday to Friday, it would be the SELECT Statement mentioned above.

What would be the right code line to add in order to have a value for Friday when the day is Monday, and -1 day when it’s Tuesday to Friday?

Thank you for you help.

Advertisement

Answer

Here is how you get -1 day for all days except for Monday ( which will now be -3 )

If you need Saturday and Sunday to also show Friday:

Or if you need Saturday and Sunday to show the current day:

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