Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-03-2004, 08:57 PM   PM User | #1
ShMiL
Regular Coder

 
Join Date: Jul 2002
Posts: 436
Thanks: 1
Thanked 0 Times in 0 Posts
ShMiL is an unknown quantity at this point
in:week number(1-52)+year/out:date of week's sunday

anyone can help?
ShMiL is offline   Reply With Quote
Old 08-04-2004, 03:25 PM   PM User | #2
ecnarongi
Regular Coder

 
Join Date: Jun 2002
Location: Northern NJ
Posts: 401
Thanks: 0
Thanked 1 Time in 1 Post
ecnarongi is an unknown quantity at this point
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.
__________________
true lies
ecnarongi is offline   Reply With Quote
Old 08-04-2004, 03:56 PM   PM User | #3
ShMiL
Regular Coder

 
Join Date: Jul 2002
Posts: 436
Thanks: 1
Thanked 0 Times in 0 Posts
ShMiL is an unknown quantity at this point
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.
ShMiL is offline   Reply With Quote
Old 08-04-2004, 05:28 PM   PM User | #4
ecnarongi
Regular Coder

 
Join Date: Jun 2002
Location: Northern NJ
Posts: 401
Thanks: 0
Thanked 1 Time in 1 Post
ecnarongi is an unknown quantity at this point
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?
__________________
true lies
ecnarongi is offline   Reply With Quote
Old 08-04-2004, 05:47 PM   PM User | #5
ShMiL
Regular Coder

 
Join Date: Jul 2002
Posts: 436
Thanks: 1
Thanked 0 Times in 0 Posts
ShMiL is an unknown quantity at this point
eXactly!
ShMiL is offline   Reply With Quote
Old 08-06-2004, 02:50 PM   PM User | #6
ecnarongi
Regular Coder

 
Join Date: Jun 2002
Location: Northern NJ
Posts: 401
Thanks: 0
Thanked 1 Time in 1 Post
ecnarongi is an unknown quantity at this point
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
__________________
true lies
ecnarongi is offline   Reply With Quote
Old 08-06-2004, 05:26 PM   PM User | #7
Roy Sinclair
Senior Coder

 
Join Date: Jun 2002
Location: Wichita
Posts: 3,880
Thanks: 0
Thanked 0 Times in 0 Posts
Roy Sinclair will become famous soon enough
Full week starting with a Sunday or do you count the partial week that may be as little as one day?
__________________
Check out the Forum Search. It's the short path to getting great results from this forum.
Roy Sinclair is offline   Reply With Quote
Old 08-06-2004, 06:27 PM   PM User | #8
ShMiL
Regular Coder

 
Join Date: Jul 2002
Posts: 436
Thanks: 1
Thanked 0 Times in 0 Posts
ShMiL is an unknown quantity at this point
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
ShMiL is offline   Reply With Quote
Old 08-10-2004, 06:11 AM   PM User | #9
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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.
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:48 PM.


Advertisement
Log in to turn off these ads.