Tuesday, August 14, 2012

How to find the Last week dates from Monday to Sunday in SQL Server


declare @Start  datetime 
declare @End datetime 
set @Start=DATEADD(wk, DATEDIFF(wk,0,GETDATE()-7), 0)
set @End=DATEADD(wk, DATEDIFF(wk,0,GETDATE()-7), 6)
select @Start as Monday
select @End as Sunday

No comments:

Post a Comment