CDate Function

Named Arguments





Use: Required

Data Type: String or Numeric

Any valid date expression.

Return Value

expression converted into a Date data type.


Converts expression to a Date data type. The format of expression—the order of day, month, and year—is determined by the locale setting of your computer. To be certain of a date being recognized correctly by CDate, the month, day, and year elements of expression must be in the same sequence as your computer's regional settings; otherwise the CDate function has no idea that 4 is supposed to be the 4th of the month, not the month of April.

CDate also converts numbers to a date. The precise behavior of the function, however, depends on the value of expression :

  • If expression is less than or equal to 23 and includes a fractional component less than 60, the integer is interpreted as the number of hours since midnight, and the fraction is interpreted as the number of seconds.

  • In all other cases, the integer portion of expression is converted to a date that interprets the integer as the number of days before (in the case of negative numbers) or after December 31, 1899, and its fractional part is converted to the time of day, with every .01 representing 864 seconds (14 minutes 24 seconds) after midnight.

Rules at a Glance

  • CDate accepts both numerical date expressions and string literals. You can pass month names into CDate in either complete or abbreviated form; for example, ...

Get VB & VBA in a Nutshell: The Language now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.