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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Week Number and Year.. Find the date of sunday 1

Status
Not open for further replies.

fmrock

Programmer
Sep 5, 2006
510
US


I have the WeekNumber and Year. I would like to use those to figure out the Sunday's date (First of the week.)

Any ideas? I have googled with no real luck.
 
Code:
<%

nYear = 2010
nWeek = 10
dStartDate = DateAdd("ww", nWeek,  dateserial(nYear,1,1) ) 

do while true
 if Weekday(dStartDate) = 1 then
  exit do
 end if
 dStartDate = dateadd("d",1,dStartdate)
loop

response.write "The sunday in week " & nWeek & " of " & nYear & " = " & dStartDate

%>
 
Thanks Foxbox,

This is how i figured it out yesterday.

Code:
varTempDate = CDate("01/01/" & varYear_Param) - WeekDay("01/01/" & varYear_Param, vbSunday) + 1
varTempDate = varTempDate + 7 * (varWeek_Param - 1)

varDateRange_StartDate=varTempDate
varDateRange_EndDate=DateAdd("d",6,varDateRange_StartDate)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top