Description
Returns a date containing the time for a specific hour, minute, and second.
Syntax
TimeSerial(hour,minute,second)
The TimeSerial function syntax has these named-argument parts:
Part |
Description |
hour |
Number between 0 (12:00 A.M.) and 23 (11:00 P.M.), inclusive, or a numeric expression. |
minute |
Number between 0 and 59, inclusive, or a numeric expression. |
second |
Number between 0 and 59, inclusive, or a numeric expression. |
Remarks
To specify a time, such as 11:59:59, the range of numbers for each TimeSerial argument should be in the normally accepted range for the unit; that is, 0-23 for hours and 0-59 for minutes and seconds. However, you can also specify relative times for each argument using any numeric expression that represents some number of hours, minutes, or seconds before or after a certain time. The following example uses expressions instead of absolute time numbers. The TimeSerial function returns a time for 15 minutes before (0 - 15) six hours before noon (12 - 6), or 5:45:00 A.M.
TimeSerial(12 - 6, 0 - 15, 0)
If the time specified by the three arguments, either directly or by expression, falls outside the acceptable range of times, an error occurs.
See Also
DateSerial Function, DateValue Function, Hour Function, Minute Function, Now Function, Second Function, TimeValue Function.
Example
This example uses the TimeSerial function to return a time for the specified hour, minute and second.
' MyTime contains the time for 4:35:17 PM MyTime = TimeSerial(16, 35, 17) ' Return time.