Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculating the Date from the week Number 1

Status
Not open for further replies.

NotSQL

Technical User
May 17, 2005
205
GB
Hi,

I currently have a table looking like this

Year Wk percent
2006 1 1.6
2006 2 2.0
2006 3 2.3
2006 4 1.7
2006 5 2.1


what I would like is the corresponding date that is associated with the week number. So in the long run i'd have a table that looks like this....
table that looks like this....

Year Wk Percent Date
2006 1 1.6 (associatedDate)

 
First weekday is Sunday or Monday?
"Regular" or ISO week of year?

------
Theory: everybody knows everything, nothing works
Practice: everything works, nobody knows why

[banghead]
 
If poosible can i have both?

cheers
 
Both Sunday and Monday? Choose one :)

------
Theory: everybody knows everything, nothing works
Practice: everything works, nobody knows why

[banghead]
 
Do you mean something like this?

Code:
declare @year varchar(4)
set @year = '2006'

declare @weekno int
set @weekno = 1

select dateadd(d, -datepart(dw, @year + '0101') + 1 + 7 * (@weekno - 1), @year + '0101') as WeekStart
select dateadd(d, -datepart(dw, @year + '0101') + 1 + 7 * (@weekno - 1) + 6, @year + '0101') as WeekEnd

[vampire][bat]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top