MS Excel: CDate Function (VBA only)
In Excel, the CDate function converts a value to a date.
The syntax for the CDate function is:
CDate( expression )
expression must be a valid date.
Applies To:
- Excel 2007, Excel 2003, Excel XP, Excel 2000
VBA Code
The CDate function can only be used in VBA code. For example:
Dim LstrDate As String
Dim LDate As DateLstrDate = "Apr 6, 2003"
LDate = CDate(LstrDate)
In this example, the variable LDate would now contain the value 4/6/2003.