Microsoft KB Archive/121012

= ACC2: DatePart, DateDiff Functions Ignore Global Settings =

Article ID: 121012

Article Last Modified on 6/24/2002

-

APPLIES TO


 * Microsoft Access 2.0 Standard Edition

-



This article was previously published under Q121012



Novice: Requires knowledge of the user interface on single-user computers.



SUMMARY
In Microsoft Access, you can use the First Week and First Weekday options settings to specify values other than the default values of January 1 for the first week, and Sunday for the first week day.

If you do use these option settings to change the default values, you must specify the optional setting when you use either the DatePart or the DateDiff function.

To change these option settings, click Options on the View menu, select General in the Category box, and then in the Items box select the option you want to change.



MORE INFORMATION
In Microsoft Access, two new parameters have been added to the DatePart and DateDiff functions. The new parameters are FirstWeek and FirstWeekDay. If you change the default setting for the First Week or the First Weekday option, you must explicitly define the matching parameter when you use the DatePart or DateDiff function.

For example, if you set the First Week option setting to First Full Week, and the First Weekday option setting to Monday, use the following syntax for the DateDiff and DatePart functions:


 * DateDiff("ww","11/1","11/30",2,3)

-or-

DateDiff("ww","11/1","11/30",MONDAY,3)

-or-

DateDiff("ww","11/1","11/30",MONDAY,0)
 * DatePart("w","31-Dec",2,3)

-or-

DatePart("w","31-Dec",MONDAY,3)

-or-

DatePart("w","31-Dec",MONDAY,0)

