Start/End Dates for a Week

Discussion in 'ASP General' started by Bullschmidt, Oct 14, 2005.

  1. Bullschmidt

    Bullschmidt Guest

    If I know the week number and the year, how can I calc the beginning and
    ending dates of the week?

    For background I'm going to do some grouping by week but don't just want
    to call the weeks Week 25, Week 26, Week 27, etc.

    Thanks in advance,
    J. Paul Schmidt, Freelance Web and Database Developer
    http://www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Bullschmidt, Oct 14, 2005
    #1
    1. Advertising

  2. Bullschmidt

    Evertjan. Guest

    Bullschmidt wrote on 14 okt 2005 in
    microsoft.public.inetserver.asp.general:

    > If I know the week number and the year, how can I calc the beginning and
    > ending dates of the week?
    >
    > For background I'm going to do some grouping by week but don't just want
    > to call the weeks Week 25, Week 26, Week 27, etc.
    >



    Dr John Stockton on Feb 16 2004, 8:32 pm wrote here:
    <http://groups.google.com/group/alt.comp.lang.borland-
    delphi/msg/c510a6cb062cbc4c>
    > Be very careful about advice from America; AIUI, over there they have
    > more different week number standards than is really desirable. Be
    > careful to test any function you choose rather exhaustively, covering
    > all 14 combinations of leapness and day-of-week of Jan 1st and checking
    > both ends of the year.
    >
    > Probably you want the ISO-8601 standard week number, for which see
    > <URL:http://www.merlyn.demon.co.uk/weekinfo.htm>,
    > <URL:http://www.merlyn.demon.co.uk/wknotest.txt>, and
    > <URL:http://www.merlyn.demon.co.uk/programs/dateprox.pas>.


    These are a good start, methinks, Paul.

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Oct 14, 2005
    #2
    1. Advertising

  3. Bullschmidt wrote:
    > If I know the week number and the year, how can I calc the beginning
    > and ending dates of the week?
    >
    > For background I'm going to do some grouping by week but don't just
    > want to call the weeks Week 25, Week 26, Week 27, etc.
    >


    First of all, define "week". The definition can depend on locale.

    My recommendation is to use a calendar table in a database, especially if
    your weeks are non-standard (e.g., fiscal weeks). Even if the weeks are
    "standard", you can get many benefits besides week start/end dates from a
    calendar table.
    http://www.aspfaq.com/show.asp?id=2519

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
     
    Bob Barrows [MVP], Oct 14, 2005
    #3
  4. Bullschmidt

    Bullschmidt Guest

    <<First of all, define "week". The definition can depend on locale.>>

    DatePart("WW", [MyDateField])


    Best regards,
    J. Paul Schmidt, Freelance Web and Database Developer
    http://www.Bullschmidt.com
    Access Database Sample, Web Database Sample, ASP Design Tips

    *** Sent via Developersdex http://www.developersdex.com ***
     
    Bullschmidt, Oct 14, 2005
    #4
  5. Bullschmidt

    Evertjan. Guest

    Bullschmidt wrote on 14 okt 2005 in
    microsoft.public.inetserver.asp.general:

    > <<First of all, define "week". The definition can depend on locale.>>
    >
    > DatePart("WW", [MyDateField])
    >


    From the specs:

    firstdayof week
    Optional. Constant that specifies the day of the week. If not specified,
    Sunday is assumed. See Settings section for values.

    firstweekofyear
    Optional. Constant that specifies the first week of the year. If not
    specified, the first week is assumed to be the week in which January 1
    occurs. See Settings section for values.

    That your definitions?

    --
    Evertjan.
    The Netherlands.
    (Replace all crosses with dots in my emailaddress)
     
    Evertjan., Oct 14, 2005
    #5
  6. Bullschmidt wrote:
    > <<First of all, define "week". The definition can depend on locale.>>
    >
    > DatePart("WW", [MyDateField])
    >
    >

    That's not what I meant:

    Does the week start on Sunday or Monday in your locale?
    Does the designation of 1 to a week depend on which day of the week 1-Jan
    falls?

    Using a calendar table makes these questions irrelevant, since you (or the
    person entering the data into the calendar table) will have absolute control
    over the week numbers used for each date.

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows [MVP], Oct 14, 2005
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    3
    Views:
    1,881
    Alexandre
    Dec 22, 2003
  2. David Lozzi

    Dates dates dates dates... SQL and ASP.NET

    David Lozzi, Sep 29, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    904
    Rob Schieber
    Sep 30, 2005
  3. =?Utf-8?B?SklNLkgu?=

    Q: quarter's start and end dates

    =?Utf-8?B?SklNLkgu?=, Nov 23, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    1,058
    Karl Seguin
    Nov 23, 2005
  4. Tim Chase
    Replies:
    3
    Views:
    709
    Tim Chase
    Jun 9, 2006
  5. PW

    Dates! Dates! Dates!

    PW, Aug 7, 2004, in forum: ASP General
    Replies:
    4
    Views:
    230
    Mark Schupp
    Aug 9, 2004
Loading...

Share This Page