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

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

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.
https://en.wikipedia.org/wiki/ISO_week_date[^]

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!
 
Share this answer
 
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
 
Share this answer
 

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