Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

This article was previously published under Q248377

↑ Back to the top


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.

↑ Back to the top


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.

↑ Back to the top


More information

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

↑ Back to the top


Keywords: KB248377, kbprb

↑ Back to the top

Article Info
Article ID : 248377
Revision : 6
Created on : 10/11/2006
Published on : 10/11/2006
Exists online : False
Views : 338