Get last day of the month in SQL Server

A quick way to get the last day of the month:

declare @date dateTime;
set @date = convert(DateTime,'2013/12/01');
SELECT DATEADD(dd, -DAY(DATEADD(m,1,@date)), DATEADD(m,1,@date))

Advertisements