DATEVALUE

DATEVALUE(date)

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


dateThe date you want converted (String).

REMARKS
* This function uses your Local Settings for the format of the returned value.
* This function recognizes the order for month, day, and year according to the Short Date format you specified for your system.
* 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 times according to the TIMEVALUE function.
* This function is very similar to the CDATE function.
* You can use the CDATE function to return an expression converted to a Date data type.
* You can use the DATE function to return the current system date.
* You can use the DATEADD function to return the date with a specified time interval added.
* You can use the DATEDIFF function to return the number of a given time interval between two specified dates.
* You can use the DATEPART function to return the specified part of a given date.
* You can use the DATESERIAL function to return the date given a year, month and day.
* 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 learn.microsoft.com

Debug.Print DateValue("February 12, 1969")     '= 12/02/1969  
Debug.Print DateValue("July, 19, 2024") '= 19/07/2024
Debug.Print DateValue("12/30/07") '= 30/12/2007
Debug.Print DateValue("12/30/2007") '= 30/12/2007
Debug.Print DateValue("12/30/24") '= 30/12/2024
Debug.Print DateValue("12/30/2024") '= 30/12/2024
Debug.Print DateValue("December, 30 2024") '= 30/12/2024
Debug.Print DateValue("December 30, 2024") '= 30/12/2024
Debug.Print DateValue("30 Dec, 2024") '= 30/12/2024
Debug.Print DateValue("Dec 30, 2024") '= 30/12/2024
Debug.Print DateValue("12/30/2024 12:40:13") '= 30/12/2024
Debug.Print DateValue("12/30/2024 12:90:30") 'Error 13 '90 minutes is not valid
Debug.Print DateValue("29/2/2024") 'Error 13 '2022 is not a leap year
Debug.Print DateValue("29/2/2024") 'Error 13 '2024 is a leap year

Dim lserial As Long
lserial = DateValue("12 Jul 2024")
Debug.Print lserial '= 45485

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