Microsoft KB Archive/286453

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

Article ID: 286453

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Access 2002 Standard Edition

-



This article was previously published under Q286453



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 2000 version of this article, see 214701.



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 being 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, click Options on the Tools menu, 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 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 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. The following segment of code returns the current database-level setting: If GetOption(&quot;Four-Digit Year Formatting&quot;) = True Then MsgBox &quot;This database is using four-digit year formatting.&quot; Else MsgBox &quot;This database is not using four-digit year formatting.&quot; End If The following segment of code forces Access to use four-digit year formatting at the database-level: SetOption &quot;Four-Digit Year Formatting&quot;, True The following segment of code returns the current application-level setting: If GetOption(&quot;Four-Digit Year Formatting All Databases&quot;) = True Then MsgBox &quot;Access is using four-digit year formatting.&quot; Else MsgBox &quot;Access is not using four-digit year formatting.&quot; End If The following segment of code forces Access to use four-digit year formatting at the application-level: SetOption &quot;Four-Digit Year Formatting All Databases&quot;, True

