CDATE(expression)

Returns the expression converted to a date data type (Date).


expressionThe expression to evaluate and convert to a date.

REMARKS
* This function refers to your local settings when converting to dates.
* The "expression" can be any valid date expression.
* If the expression passed to the function is outside the range of the data type being converted to, an error occurs.
* Date and time literals are recognised ??
* This function does not recognise the names for the days of the week.
* If the year is not specified in the date, then the current year is used.
* You should not use the CVDATE function.
* For a full list of conversion functions refer to the Explicit Conversion page.
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print CDate(36114)          '= "15/11/1998"  
Debug.Print CDate("4 Mar 2010") '= "04/03/2010"

Dim dtBirthday As Date
Dim sDateTime As String
sDateTime = "01/071977 12:00:26"
dtBirthday = CDate(sDateTime)
Debug.Print dtBirthday

dtBirthday = #1/12/2004#
Debug.Print CDate(dtBirthday) '= "12/01/2004"

dtBirthday = #12/1/2004#
Debug.Print CDate(dtBirthday) '= "01/12/2004"

© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited Top