Name
TimeValue Function
Syntax
TimeValue(time)-
time Use: Required
Data Subtype: String
Any valid string representation of a time.
Return Value
A Variant of subtype Date.
Description
Converts a string representation of a time to a Variant Date subtype.
Rules at a Glance
If
timeis invalid, a runtime error is generated.If
timeisNull,TimeValuereturnsNull.Both 12- and 24-hour clock formats are valid.
Any date information contained within
timeis ignored by theTimeValuefunction.If
TimeValuewill return invalid time information, an error occurs.
Programming Tips & Gotchas
A time literal can also be assigned to a Variant or Date variable by surrounding the date with hash characters (
#), as the following snippet demonstrates:Dim dMyTime dMyTime = #12:30:00 AM#
The
CDatefunction can also cast a time expression contained within a string as a Date variable, with the additional advantage of being internationally aware.
See Also
| CDate Function , TimeSerial Function |
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access