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