Click here to Skip to main content
15,065,783 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
we are providing present week number how to get dates in that week

Thanks & Regards
Updated 31-Oct-15 0:06am

That's complicated, because "week number" doesn't relate to a fixed start date: January the first of a particular year can be in week 50, 51, or 52 of the previous year, or week 1 of the current year - and depending on when that is controls what date the current week starts with.[^]

What I would do set up a table which indexes by year and provides the start date for week 1 of each year, and then add the week number times 7 to that to get the actual date.
Or you could follow the algorithm in the link!
DECLARE @WeekNo int= 15
DECLARE @Year int=2013

SELECT DATEADD(wk,@WeekNo-1,DATEADD(yy,@Year-1900,0)) AS WeekStart,
DATEADD(wk,@WeekNo,DATEADD(yy,@Year-1900,0))-1 AS WeekEnd

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900