I know this is quite a generic question but does anyone know a good way of checking if the date is the last monday of the month using T-SQL. I need to use it in a stored procedure to determine if the stored procedure returns data or does nothing.
Cheers!
The following select will return
1if the current date is the last monday of the month, and0if not.datepart(dw, GETDATE())returns the day of the week. Monday is 2. The second part adds 7 days to the current date and checks that within 7 days the month has changed (if it does not, it is not the last monday).Change the
GETDATE()‘s to any date you want to check.EDIT:
You can make it into a generic function and use it with any date you like: