Returns the date given a string representation of a date (Date).

dateThe date you want converted (String).

* The "date" can be a string expression representing a date from January 1, 100 through December 31, 9999.
* The "date" can also be any expression that can represent a date, a time, or both a date and time, in that range.
* If "date" is a string that includes only numbers separated by valid date separators.
* If the year part of the date is not provided, then the current year is used.
* If "date" includes valid time information, then the time information is ignored.
* If "date" includes any invalid date or time information, then an error occurs. Type Mismatch.
* This function recognizes the order for month, day, and year according to the Short Date format you specified for your system.
* This function recognizes times according to the TIMEVALUE function.
* This function is very similar to the CDATE function.
* You can use the CDATE function to return the expression converted to a date data type.
* You can use the FORMAT function to return a text string of a date in a particular format.
* The equivalent .NET function is Microsoft.VisualBasic.DateAndTime.DateValue
* For the Microsoft documentation refer to

Debug.Print DateValue("February 12, 1969")     '12/02/1969  
Debug.Print DateValue("July, 19, 2004") '19/07/2004
Debug.Print DateValue("12/30/07") '30/12/2007
Debug.Print DateValue("12/30/2007") '30/12/2007
Debug.Print DateValue("December, 30 2007") '30/12/2007
Debug.Print DateValue("December 30, 2007") '30/12/2007
Debug.Print DateValue("30 Dec, 2007") '30/12/2007
Debug.Print DateValue("Dec 30, 2007") '30/12/2007
Debug.Print DateValue("12/30/2007 12:40:13") '30/12/2007
Debug.Print DateValue("12/30/2007 12:90:30") 'Error 13 '90 minutes ??
Debug.Print DateValue("29/2/2000") 'Error 13 '2000 is a leap year

Dim lserial As Long
lserial = DateValue("12 Jul 2013")
Debug.Print lserial

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