ACC2: Displaying Years 2000 and Later for Short Date Data TypeLast reviewed: March 17, 1998Article ID: Q132067 |
The information in this article applies to:
SUMMARYThis article describes two methods that you can use on a field formatted for the Short Date data type so that it displays a year later than 1999.
MORE INFORMATIONUnless you explicitly enter the year in a date field as 2000 or later, Microsoft Access saves the year portion as 1900 - 1999 as appropriate. For example, if a field has the Date/Time data type, and you type the date as 01/01/00, Microsoft Access saves the year portion internally as 1900. If you enter the date as 01/01/2000, Microsoft Access saves the year portion internally as 2000. However, the date still appears in the date field as 01/01/00 if displayed using the Short Date format There are two methods you can use to display fields formatted for the Short Date data type with years later than 1999; however, both methods have limitations in that they add 100 years to the input date only if the last two digits in the date are 00 through 49, inclusive. Therefore, these methods work accurately only for dates between the years 1950 and 2049, inclusive.
Method 1Method 1 adds a procedure to the field's AfterUpdate event that checks the year, and if the year is less than 1950 (that is, the last two digits are 00 through 49), it adds 100 years to the date. To use this method, follow these steps:
Method 2Method 2 uses the expression below in the Update To line in an update query. You can use this method if you have a table that already contains dates that you want to convert to the year 2000 and later. The expression assumes the name of the field you want to update is myDateField. Substitute the name of the field in your table for the myDateField field in the expression below. NOTE: In the following expression, an underscore (_) at the end of a line is used as a line-continuation character. Remove the underscore from the end of the line when re-creating this expression.
iif(Year([myDateField]) < 1950, DateAdd("yyyy", 100, [myDateField]), _ [myDateField]) |
Additional query words: Y2K Year 2000 millennium two-thousand two thousand
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |