contents.gifindex.gifprev1.gifnext1.gif

CVDate

Purpose

Converts an expression to a Variant of VarType 7 (date).

Arguments

CVDate( expression )

Notes

The argument expression must be a string expression or a numeric expression that can be interpreted as a date. The acceptable range for date information is from January 1, A.D. 100 (-657434) through December 31, A.D. 9999 (2958465).

The following table identifies the action that occurs as a result of evaluating expression.

If expression is this type
CVDate takes this action
A numeric expression between -657434 and 2958465, inclusive
Considers expression to already be a date serial and makes no change
A numeric expression less than -657434 or greater than 2958465
Generates a run-time error
A numeric expression that looks like a date, for example, "1 January 1994 12:00 PM"
Converts expression to a date serial, for example, 34335.5
A numeric expression that looks like a number, for example, "33664"
Converts expression to a date serial, for example, 33664

For string expressions, CVDate recognizes all the date formats that can be set in the International section of the WIN.INI file using the Microsoft Windows Control Panel.


You can use the IsDate function to determine whether a string expression can be converted to a date. You should explicitly test numeric expressions to ensure that they fall within the range of acceptable dates.

When converting from a date serial to date format, Access Basic converts any fractional part of the numeric expression to a time of day, starting at midnight.

Example

This example returns a Variant of VarType 7 that contains a Date data type equal to 34370.

X = CVDate( "5 February 1994" )