Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts

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

    anyone can help?

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post
    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.
    I would rather be a lion for a day than a lamb that lives forever.

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post
    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?
    I would rather be a lion for a day than a lamb that lives forever.

  • #5
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    eXactly!

  • #6
    Regular Coder
    Join Date
    Jun 2002
    Location
    Northern NJ
    Posts
    404
    Thanks
    0
    Thanked 1 Time in 1 Post
    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
    I would rather be a lion for a day than a lamb that lives forever.

  • #7
    Senior Coder
    Join Date
    Jun 2002
    Location
    Wichita
    Posts
    3,880
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Posts
    436
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,043
    Thanks
    0
    Thanked 251 Times in 247 Posts
    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
    •