Find Last Day of Any Month date – Current Previous Next


----Last Day of Previous Month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) as LastDay_PreviousMonth
----Last Day of Current Month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0)) as LastDay_CurrentMonth
----Last Day of Next Month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+2,0)) as LastDay_NextMonth




ResultSet:
LastDay_PreviousMonth
———————–
2012-03-31 10:59:59.000

LastDay_CurrentMonth
———————–
2012-04-30 10:59:59.000

LastDay_NextMonth
———————–
2007-05-31 23:59:59.000 

Comments

Popular posts from this blog

GROUP BY, CUBE, ROLLUP and SQL SERVER 2005

How to get content of Ckeditor & Fckeditor using Javascript

How to Fix Error- Sys.WebForms.PageRequestManagerTimeoutException - The server request timed out