Friday, March 11, 2011

Weeks In SQL - Start and End days of a week.

Declare @Date datetime = '03/15/2011' ------- Your Date

select dateadd(day,( -datepart(weekday,dateadd(day,(7)-datepart(weekday,@Date),@Date))+((7)-datepart(weekday,@Date)))+(1),@Date) AS [First_Day_Of_The_Week]

Select dateadd(day,(7)-datepart(weekday,@Date),@Date) AS [Last_Day_Of_The_Week]