Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.

# Thread: in:week number(1-52)+year/out:date of week's sunday

1. ## in:week number(1-52)+year/out:date of week's sunday

anyone can help?

• do you just want to know what day(sun.-sat.) today is? do you want to know what is the date of the next (sun.-sat.) is? please clarify? ask specific questions and get specific answers.

• We are now at the 31 week of the year.
the output for 31 would be: 01/08/04 (which is the date of 31 week's sunday).
another ex:
the output for week 34 (year 2004) would be: 15/08/04
the output for week 34 (year 2005) would be: 14/08/04

do you understand?

Thanks alot.

• ok, so you want to give the script the year and the week, and for the script to output the date for the sunday of that week in that year?

• eXactly!

• I am looking to do the same thing I am currently working on a solution, so if you come up with a solution before I please post. Thanks

• Full week starting with a Sunday or do you count the partial week that may be as little as one day?

• full week starting with sunday...
If you look at the calender, you can see that the year is divided into 52 weeks.
starting on the first sunday of Jan and ending at the 4th sunday of Dec.
I'd like to get the date of those sundays by entering the year and the week number...
I looked for some functions that has something to do with week number... but couldn't find any...
Did you hear of functions of this kind?

Thanks

• Try this:
Code:
```<%
function getSundayOfWeek(weekNum, year)
dim dNewYear, dFirstSunday
dNewYear = "1/1/" & year 'm/d/yyyy
dFirstSunday = weekday(dNewYear)
if dFirstSunday = 1 then 'sunday already
dFirstSunday = dNewYear
else 'not sunday so get next sunday
dFirstSunday = "1/" & (2 + (7 - dFirstSunday)) & "/" & year  'm/d/yyyy
end if
getSundayOfWeek = dateadd("WW", weekNum-1, dFirstSunday) 'add weeks (subtract 1 to weeknum so that calculation is inclusive of the dFirstSunday
end function

response.write(getSundayOfWeek(52,2004)) '12/26/2004
response.write(getSundayOfWeek(31,2004)) '8/1/2004

%>```
Take note that the function uses m/d/yyyy as the dateformat which is the settings in my Regional Options (Control Panel). Tweak the code to make it dd/mm/yyyy.

•

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•