VBA CDate function

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)

CDate Function Description

The VBA CDate function converts an expression (variable) to Date data type.


The syntax for the CDate function in VBA is:

CDate( expression )


An expression / variable that is to be converted to Date data type.

Other Notes

If the expression / variable can’t be converted to a Date, the function with return Error code 13: Type mismatch.

For formatting Dates use the VBA Format function

Example usage

The CDate function can be used in VBA code. Let’s look at some VBA CDate function examples:

CDate "12/10" 
'Result: 2016-12-10 

CDate "12/10/2015" 
'Result: 2015-12-10 

CDate "12.10" 
'Result: 12:10:00

CDate "12 10" 
'Result: 2016-12-10 

Simply the best place to learn Excel VBA