Name

CDate Function

Synopsis

CDate(expression)
expression required; String or Numeric

Any valid representation of a date and time

Named Arguments

No

Return Value

expression converted into a Date data type

Description

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 the local computer. To be certain a date is recognized correctly by CDate, the month, day, and year elements of expression must be in the same sequence as the local computer’s regional settings; otherwise, the CDate function has no idea, for example, that 4 was supposed to be the fourth day of the month, not the month of April. The earliest date that can be handled by the Date data type is 01/01/100. The latest date that can be handled by the Date data type is 12/31/9999.

Get VB.NET Language Pocket Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.