Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-24-2006, 03:59 PM   PM User | #1
Gyte
New Coder

 
Join Date: Sep 2005
Posts: 25
Thanks: 1
Thanked 0 Times in 0 Posts
Gyte is an unknown quantity at this point
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?
Gyte is offline   Reply With Quote
Old 03-24-2006, 06:28 PM   PM User | #2
Archangel
Registered User

 
Join Date: Jan 2006
Posts: 130
Thanks: 0
Thanked 0 Times in 0 Posts
Archangel is an unknown quantity at this point
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.
Archangel is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 02:26 AM.


Advertisement
Log in to turn off these ads.