ACC2: DatePart(), DateDiff() Functions Ignore Global Settings

ID: Q121012


The information in this article applies to:
  • Microsoft Access 2.0


SUMMARY

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

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)



REFERENCES

For more information about the DateDiff function, search the Help Index for "DateDiff function."

For more information about DatePart function, search the Help Index for "DatePart function."

Keywords : kbusage
Version : 2.0
Platform : WINDOWS
Issue type : kbinfo


Last Reviewed: April 6, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.