QUERY TO FIND LAST DAY OF A MONTH IN SQL SERVER 2005

–QUERY TO FIND LAST DAY OF A MONTH

–Last day of previous month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())-1,0))

–Last Day of currect month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())+1,0))

–Last Day of previous month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())+0,0))

–Last Day of next month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,getdate())+2,0))

Pawan Kumar
pawankkmr@hotmail.com

Advertisements