Saturday, 17 February 2018

MSSQL - How to get last day of the month

Watch this example on YouTube


this query will get last day of the month

Declare @dt as DateTime = '2/1/2018'
Declare @LastDayOfTheMonth as DateTime = dateAdd(day, -1, dateAdd(month, 1,
dateAdd(day, 1 - day(@dt), @dt)))

Select @LastDayOfTheMonth

No comments:

Post a Comment