...

View Full Version : Bug in DatePart ?



Gyte
03-24-2006, 03:59 PM
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?

Archangel
03-24-2006, 06:28 PM
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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum