Retrieve a Date from a given Week Number.

Posted on 2006-06-07
Last Modified: 2008-02-01

I have an asp function that is required to retrieve the date, when only the day of the week, and the week number are provided.

For example, to get todays date the function is called as


as today is wednesday and this week is week number 22

the function itself so far looks like

      Function getDateFromWeek(dayOfWeek,weekNo)
            'get the date range for the week number of the current year
            getDateFromWeek = date
      End Function

as u can see - it needs a bit of work and i'm stumped!

any suggestions will be greatly apprciated!

many thanks in advance.
Question by:lunchboxbill
    LVL 31

    Expert Comment

    Can't say I really like a function like that, nor why have it...but see DATEPART:
    LVL 22

    Accepted Solution

    i guess you can only assume the current year if you dont input that.  this should get you close.

         Function getDateFromWeek(dayOfWeek,weekNo)
              'get the date range for the week number of the current year
              dim dayoffset

              select case dayOfWeek
                 case "sun"
                     dayoffset = 0
                 case "mon"
                     dayoffset = 1
                 ' etc
              end select

              startdate = datepart("yyyy",date) & "/1/1"
              getDateFromWeek = dateadd("d",dateadd("ww",startdate,weekno),dayoffset)
         End Function

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Join & Write a Comment

    Suggested Solutions

    I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
    This demonstration started out as a follow up to some recently posted questions on the subject of logging in: and…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now