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 2 of 2
  1. #1
    New Coder
    Join Date
    Sep 2005
    Posts
    25
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Bug in DatePart ?

    Hello,
    I tried to following code in ASP :

    Dim i
    For i=1990 To 2010
    Response.Write i & " weeknumber = '" & DatePart("ww", DateSerial(i, 12, 31), vbMonday, vbFirstFourDays) & "'<br>"
    Next

    The code generated the following output:

    1990 weeknumber = '1'
    1991 weeknumber = '1'
    1992 weeknumber = '53'
    1993 weeknumber = '52'
    1994 weeknumber = '52'
    1995 weeknumber = '52'
    1996 weeknumber = '1'
    1997 weeknumber = '1'
    1998 weeknumber = '53'
    1999 weeknumber = '52'
    2000 weeknumber = '52'
    2001 weeknumber = '1'
    2002 weeknumber = '1'
    2003 weeknumber = '1'
    2004 weeknumber = '53'
    2005 weeknumber = '52'
    2006 weeknumber = '52'
    2007 weeknumber = '53'
    2008 weeknumber = '1'
    2009 weeknumber = '53'
    2010 weeknumber = '52'

    I checked this out in the calender of Outlook and it turned out that the weeknumber of the year 2007 is wrong.

    Does anyone know if this is a bug in the DataPart function?

  • #2
    Registered User
    Join Date
    Jan 2006
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If I can understand what you're doing, technically I believe 2007 is actually right because a standard weeks actually starts on Sunday, not Monday. So even though the first day in 2007 is on a Monday, the day before (Sunday) is still 2006, thus making that technically week 53.


  •  

    Posting Permissions

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