Calculation of Week Start Date and Week End Date on given day in SQL
Week Start Date:
SELECT DATEADD(dd,1-Datepart(DW,getdate()),GETDATE())
Week End Date:
SELECT DATEADD(dd,7-Datepart(DW,getdate()),GETDATE())
Month Start Date
SELECT DATEADD(mm, -1,DATEADD(dd, +1, EOMONTH(GetUTCDATE())))
Month End Date
SELECT EOMONTH(GetUTCDATE())
SELECT DATEADD(dd,1-Datepart(DW,getdate()),GETDATE())
Week End Date:
SELECT DATEADD(dd,7-Datepart(DW,getdate()),GETDATE())
Month Start Date
SELECT DATEADD(mm, -1,DATEADD(dd, +1, EOMONTH(GetUTCDATE())))
Month End Date
SELECT EOMONTH(GetUTCDATE())
Comments