Description
Returns a time.
Syntax
TimeValue(time)
The time named argument is normally a string expression representing a time from 0:00:00 (12:00:00 A.M.) to 23:59:59 (11:59:59 P.M.), inclusive. However, time can also be any expression that represents a time in that range. If time contains no valid data, Null is returned.
Remarks
You can enter valid times using a 12- or 24-hour clock. For example, "2:24PM" and "14:24" are both valid time arguments.
If the time argument contains date information, TimeValue doesn't this information. However, if time includes invalid date information, an error occurs.
See Also
DateSerial Function, DateValue Function, Hour Function, Minute Function, Now Function, Second Function, TimeSerial Function.
Example
This example uses the TimeValue function to convert a string to a time. In general, it is bad programming practice to hard code dates/ times as strings as shown in this example. Use date literals instead.
MyTime = TimeValue("4:35:17 PM") ' Return time.