----Last Day of Previous Month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE()),0)) LastDay_PreviousMonth
----Last Day of Current Month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+1,0)) LastDay_CurrentMonth
----Last Day of Next Month
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,GETDATE())+2,0)) LastDay_NextMonth
--First Day of Previous Month
SELECT DATEADD(mm, DATEDIFF(m,0,GETDATE())-1,0) FirstDay_PreviousMonth
--First Day of Current Month
SELECT DATEADD(mm, DATEDIFF(m,0,GETDATE()),0) FirstDay_CurrentMonth
--First Day of Next Month
SELECT DATEADD(mm, DATEDIFF(m,0,GETDATE()),0) FirstDay_NextMonth
--First Day of Prev Week
SELECT DATEADD(DAY,-1,DATEADD(WEEK, DATEDIFF(WEEK,0,GETDATE())-1,0)) FirstDay_PreviousWeek
--First Day of Current Week
SELECT DATEADD(DAY,-1,DATEADD(WEEK, DATEDIFF(WEEK,0,GETDATE()),0)) FirstDay_CurrentWeek
--First Day of Next Week
SELECT DATEADD(DAY,-1,DATEADD(WEEK, DATEDIFF(WEEK,0,GETDATE()+7),0)) FirstDay_NextWeek
--Last Day of Prev Week
SELECT DATEADD(DAY,5,DATEADD(WEEK, DATEDIFF(WEEK,0,GETDATE())-1,0)) LastDay_PreviousWeek
--Last Day of Current Week
SELECT DATEADD(DAY,5,DATEADD(WEEK, DATEDIFF(WEEK,0,GETDATE()),0)) LastDay_CurrentWeek
--Last Day of Next Week
SELECT DATEADD(DAY,5,DATEADD(WEEK, DATEDIFF(WEEK,0,GETDATE()+7),0)) LastDay_NextWeek
No comments:
Post a Comment