Skip to main content

TimeSerial

Returns the time for a specific hour, minute, and second.

Synopsis

TimeSerial(hour,minute,second)

Arguments

hour Number between 0 (12:00AM) and 23 (11:00PM), inclusive, or a numeric expression the evaluates to a number in the range 0 through 23.
minute Any numeric expression.
second Any numeric expression.

Description

To specify a time, such as 11:59:59, the range of numbers for each TimeSerial argument should be in the 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. When any argument exceeds the accepted range for that argument, it increments to the next larger unit as appropriate. For example, if you specify 75 minutes, it is evaluated as one hour and 15 minutes. However, you cannot specify an hour value greater than 23.

The TimeSerial function, by default, returns a 12-hour clock time value with an AM or PM suffix. Leading zeros are displayed. Fractional seconds are truncated.

Examples

The following example uses expressions instead of absolute time numbers. The TimeSerial function returns a time for 15 minutes before (-15) six hours before noon (12 - 6), or 5:45:00AM

Dim MyTime
MyTime = TimeSerial(12 - 6, -15, 0) ' Returns 5:45:00 AM.
Println MyTime

See Also

FeedbackOpens in a new tab