SQLTutorials  
Powered By PhICK1.com 

SQL Last Day of a Month

SQL Statement below show the Sql query to get the last day of a month value by using sql DATEADD.
Example of SQL Statement to get last day of a month


DECLARE @DateNow DATETIME
SET @DateNow='2007-07-04'
SELECT DATEADD(dd, -DAY(DATEADD(m,1,@DateNow)), DATEADD(m,1,@DateNow)) AS LastDay

Return Value = 2007-07-31 00:00:00.000

DECLARE @DateNow DATETIME
SET @DateNow='2007-06-04'
SELECT DATEADD(dd, -DAY(DATEADD(m,1,@DateNow)), DATEADD(m,1,@DateNow)) AS LastDay

Return Value = 2007-06-30 00:00:00.000

powered by www.pHick1.com
SQLTutorials
Sql Server Related Links