SPONSORS:






User Tag List

Results 1 to 4 of 4
  1. #1
    JQ
    JQ is offline
    Junior Member
    Join Date
    Jan 2000
    Location
    Maynard,MA,USA
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Weeknumber to Date function.

    Hello. I'm using week numbers in my scripts because the SUT uses week numbers for input. It is ultimately converted into a date format in the back end database, so I need to create or use a function in my silkscript to convert the input week number to a date (string or datetype) for back end verification. I need an option for 1st day of the week and the last day of the week.

    Any ideas?

  2. #2
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Weeknumber to Date function.

    Shouldn't be too hard; there is a function I wrote called AddDays() which takes a date and int as parameters, and returns a date which is increased by the number of days specified in the other parameter. Given this (with a little bit of adaptation perhaps to make an analogous AddWeeks() function), and the date of the start of the first week of the year (Jan 1st, or April 1st, or whenever your year is running from) it should be reasonably trivial to put something together to get your date (at either the start or end of the week) out.

    My AddDays() function is basically this single line at the core of it:
    returnvalue = [date]AddDateTime([datetime]startingdate, numberdays)

    So an AddWeeks() function would be something like this:

    date AddWeeks(date startdate, int numberofweeks)
    date returnvalue
    int numberofdays = numberofweeks*7
    returnvalue = [date]AddDateTime([datetime]startdate, numberofdays)
    return returnvalue

    Hope this helps.

  3. #3
    JQ
    JQ is offline
    Junior Member
    Join Date
    Jan 2000
    Location
    Maynard,MA,USA
    Posts
    16
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Weeknumber to Date function.

    Thanks for the help. I have developed the function using the same approach as you suggested. Just as a side note, the industry I'm in doesn't use normal week numbers. They use a different calendar called the Standard Broadcast Calendar. (For TV,etc...). So this week is week 23 according to what FormatDatePart(dtNow,"ww") returns, but it is week 24 according to the SBC calendar. All I needed to do was to adjust the starting date to accomodate this. I though of posting the code, but no one else could use it because it would return the wrong date for most applications.
    Thanks again.

  4. #4
    Senior Member
    Join Date
    Aug 1999
    Location
    Cambridge, UK
    Posts
    470
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Weeknumber to Date function.

    It might be handy for somebody - I don't know about how it all works in the US, but here in the UK you have the calendar year (Jan-Dec) the academic year (Sep-Aug), the tax year (Apr-Mar), and probably millions of others. So somebody might find it useful for something if it can easily be generalised/changed.

 

 

Posting Permissions

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

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.0.9 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Questions / Answers Form provided by vBAnswers (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominatevBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 06:03 PM.

Copyright BetaSoft Inc.