The next select will return 1 if the current date is the last month of the month, and 0 if not.
select case when datepart(dw, GETDATE()) = 2 and DATEPART(month, DATEADD(day, 7, GETDATE())) <> DATEPART(month, GETDATE()) then 1 else 0 end
datepart(dw, GETDATE()) returns the day of the week. Monday - 2. The second part adds 7 days to the current date and checks that the month has changed within 7 days (if it is not, this is not the last Monday).
Change GETDATE() to any date you want to check.
EDIT:
You can do this in a generic function and use it with any date:
CREATE FUNCTION IsLastMondayOfMonth(@dateToCheck datetime) RETURNS bit AS BEGIN DECLARE @result bit SELECT @result = CASE WHEN datepart(dw, @dateToCheck) = 2 AND DATEPART(month, DATEADD(day, 7, @dateToCheck)) <> DATEPART(month, @dateToCheck) THEN 1 ELSE 0 END RETURN @result END
source share