Microsoft KB Archive/214701

= ACC2000: How to Force Access to Display Dates with Four-Digit Years =

Article ID: 214701

Article Last Modified on 6/23/2005

-

APPLIES TO


 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q214701



Moderate: Requires basic macro, coding, and interoperability skills.

This article applies to a Microsoft Access database (.mdb) and to a Microsoft Access project (.adp).

For a Microsoft Access 2002 version of this article, see 286453.



SUMMARY
Microsoft Access has two options that force Date fields and controls to display four-digit years. One option (This database) forces the display of four-digit years at the database-level in a particular database or project. The other option (All databases) forces the display of four-digit years at the application-level in all databases and projects.

The reason for these options is to make sure the user is aware of which century is used. These options only affect the format of the date. Access stores dates as serial numbers. For example, when you type the date 4/16/50 (April 16, 1950) it is actually stored as the serial number 18369. The date April 16, 2050 is stored as the serial number 54894.



MORE INFORMATION
To access these two options from the user interface, on the Tools menu, click Options, and then click the General tab. In the Use four-digit year formatting area, the This database check box controls the database-level option and the All databases check box controls the application-level option.

If either of these options is set, Access overrides the specified date format to show a four-digit year. The year portion of the date is the only part affected. Other parts of the date still rely on the Windows Regional Settings and Date formats.

The database-level option is stored in the Microsoft Access database (MDB) or Microsoft Access project (ADP). This allows developers to deliver year 2000-compliant applications regardless of the user's Regional Settings.

The application-level option is stored in the Windows Registry with all the other Access settings. This allows administrators to force all Access applications on the computer to use four-digit years, regardless of the Regional Settings, Date formats, or the database-level option.

You can programmatically check or set these options with the GetOption and SetOption methods respectively.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Use the following segment of code to determine the current database-level setting: If GetOption("Four-Digit Year Formatting") = True Then MsgBox "This database is using four-digit year formatting." Else MsgBox "This database is not using four-digit year formatting." End If The following segment of code forces Access to use four-digit year formatting at the database-level: SetOption "Four-Digit Year Formatting", True The following segment of code determines the current application-level setting: If GetOption("Four-Digit Year Formatting All Databases") = True Then MsgBox "Access is using four-digit year formatting." Else MsgBox "Access is not using four-digit year formatting." End If The following segment of code forces Access to use four-digit year formatting at the application-level: SetOption "Four-Digit Year Formatting All Databases", True For additional information about dates in Access, please see the following article in the Microsoft Knowledge Base:

208339 ACC2000: Years 00-29 Default to Year 2000 When Typed as M/D/YY

