[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 552
  • Last Modified:

Retrieve a Date from a given Week Number.

Hi,

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

//
               getDateFromWeek("wed",22)
//

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.
0
lunchboxbill
Asked:
lunchboxbill
1 Solution
 
alorentzCommented:
Can't say I really like a function like that, nor why have it...but see DATEPART:

http://www.w3schools.com/vbscript/func_datepart.asp
0
 
WMIFCommented:
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
//
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now