Microsoft KB Archive/248377

= OFF2000: CDate, CVDate Functions Unexpectedly Return Two-Digit Years =

Article ID: 248377

Article Last Modified on 10/11/2006

-

APPLIES TO


 * Microsoft Excel 2000 Standard Edition
 * Microsoft Word 2000 Standard Edition
 * Microsoft PowerPoint 2000 Standard Edition
 * Microsoft Access 2000 Standard Edition

-



This article was previously published under Q248377



SYMPTOMS
When you use the CDate function or CVDate function in the programs listed in the "Applies To" section of this article, the date returned by the function may be a two-digit year, although the function returns a four-digit year in earlier versions of the program.



CAUSE
The criteria that CDate and CVDate use to determine the format of their return value has changed in Microsoft Office 2000. See the "More Information" section of this article for a list of the criteria that the CDate and CVDate functions use to determine the format of their return value.



Criteria Used to Determine Format of Date Returned by CDate, CVDate
The CDate and CVDate functions return a two-digit year when both of the following conditions are true:
 * The Short date style setting in Regional Settings on the Control Panel is set to a format that displays two-digit years.

-and-


 * The date returned falls within a specific range of years. If you are running Windows 95 or Windows NT, the range is between 1930 and 2029. In Windows 98 and Windows 2000, this range is determined by the When a two-digit year is entered, interpret as a year between setting (on the Date tab, in Regional Options on the Control Panel).

The CDate and CVDate functions return a four-digit year when either of the following conditions is true:
 * The Short date style setting in Regional Settings on the Control Panel is set to a format that displays four-digit years.

-or-


 * The date returned falls outside of a specific range of years. If you are running Windows 95 or Windows NT, the range is between 1930 and 2029. In Windows 98 and Windows 2000, this range is determined by the When a two-digit year is entered, interpret as a year between setting (on the Date tab, in Regional Options on the Control Panel).

Examples
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.

Example 1
The following line of code CDate("1/1/2001") returns the following value if you are running Windows 95 and the Short date style setting in Regional Settings on the Control Panel is set to a format that displays two-digit years:

1/1/01

The above line of code returns the following value if the Short date style setting in Regional Settings on the Control Panel is set to a format that displays four-digit years, regardless of the version of Windows that you are running:

1/1/2001

Example 2
The following line of code CDate("1/1/1950") returns the following value if the Short date style setting in Regional Settings on the Control Panel is set to a format that displays two-digit years:

1/1/50

The above line of code returns the following value if the When a two-digit year is entered, interpret as a year between setting (on the Date tab, in Regional Options on the Control Panel) is set to a value of 2055:

1/1/1950

Additional query words: OFF2000 y2k

Keywords: kbprb KB248377

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.