TIMEVALUE(time)

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


timeThe time as a string (String).

REMARKS
* If "time" is Null, then Null is returned.
* If "time" includes date information, then the date information is ignored.
* If "time" includes any invalid date or time information, then an error occurs. Type Mismatch.
* This function recognises both 12-hour and 24-hour clock. For example, "2:24PM" and "14:24".
* This function recognises dates according to the DATEVALUE function.
* You can use the NOW function to return the current system date and time.
* You can use the TIME function to return the current system time.
* You can use the TIMESERIAL function to return the time for a specific hour, minute and second.
* The equivalent .NET function is Microsoft.VisualBasic.DateAndTime.TimeValue
* For the Microsoft documentation refer to docs.microsoft.com

Debug.Print TimeValue("4:35:17 PM")           '=  
Debug.Print TimeValue("12:30") '= "12:30:00"
Debug.Print TimeValue(VBA.Time()) '= 16:36:53
Debug.Print TimeValue(VBA.Now()) '= 16:36:53
Debug.Print TimeValue(VBA.Time() + 1) '= 16:36:53
Debug.Print TimeValue(VBA.Time() + 0.5) '= 04:36:53
Debug.Print TimeValue(VBA.Time() + (1 / 24)) '= 17:36:53
Debug.Print TimeValue(VBA.Time() + 2) '= 16:36:53
Debug.Print TimeValue("12:90:30") '= Error 13 ' 90 minutes
Debug.Print TimeValue("29/2/2000 12:30:30") '= Error 13 ' 2000 is a leap year

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