datepart returns erroneous week number?

  • Thread starter Thread starter Rick_DD
  • Start date Start date
R

Rick_DD

I may have discovered a problem with the datepart function.

I inserted this as an expression field in a query:
test: DatePart("ww",#12/30/1991#,2,2)

With the provided optional arguments to the function (firstdayofweek
=2=vbMonday, firstweekofyear=2=vbFirstFourDays), the result should be "1" but
it returns "53".

According to MS Outlook calendar, plus another independent source, this date
is a monday. Thus 1/1/1992 is a Wednesday, and with 1/1 thru 1/5 in the same
week, should be considered week 1.

Does anybody else get the same results? Am I doing something wrong?
 
That's interesting.

I don't really have an answer, but it apparently has something to do with
the following year being a leap year. All of the following dates are Mondays.

DatePart("ww",#12/30/1991#,2,2)

returns 53 (1992 is a leap year)


DatePart("ww",#12/30/1996#,2,2)

returns 1


DatePart("ww",#12/30/2013#,2,2)

returns 1 (2014 is not a leap year)


DatePart("ww",#12/30/2019#,2,2)

returns 53 (2020 is a leap year)


Based on the help file, it doesn't *seem* like leap year should have an effect
on the results, but apparently it does. In each of the leap year cases, if you
change FirstDayOfWeek to Sunday, it returns 1.

Like I said, I don't really have an answer for you, but then I'm not
always the sharpest tool in the shed :-)
 
Back
Top