CDate Function

Converts an expression to a Date value. The expression argument is any valid date expression.

CDate (Expression)

Return Value

Returns an expression that has been converted to a Date value.

Use the IsDate function to determine if date can be converted to a date or time. CDate recognizes date literals and time literals as well as some numbers that fall within the range of acceptable dates. When converting a number to a date, the whole number portion is converted to a date. Any fractional part of the number is converted to a time of day, starting at midnight.

CDate recognizes date formats according to the locale setting of your system. The correct order of day, month, and year may not be determined if it is provided in a format other than one of the recognized date settings.

Examples

CDate ("12/12/2010")

Returns the date value for December 12, 2010. 

TIP:

Functions are specifically for use in the Macro Editor. Refer to Microsoft's official VB and JScript documentation for scripting equivalents.

See Also

CBool function | CCur function | CDbl function | CDec function | CInt function | CStr function | CUInt function


© 2004-2021 looksoftware. All rights reserved.