Search This Blog

Wednesday, March 6, 2013

Last date of the month SQL Server

SQL Server > Built-In Functions > EOMONTH

EOMONTH returns the last day of the month that contains the specified date
 
SELECT EOMONTH(GETDATE())

For older editions ( < SQL Server 2012 )

SELECT CAST(DATEADD(d,-1,(DATEADD(mm,DATEDIFF(m,0,GETDATE())+1,0)))AS DATE)