Access: TimeSerial Function

In Access, the TimeSerial function returns the time for a specific hour, minute, and second.

The syntax for the TimeSerial function is:

TimeSerial ( hour, minute, second )

The TimeSerial function returns a time that is stored internally as a double-precision fractional number between 0 and 0.99999. This number represents a time between 0:00:00 and 23:59:59, or 12:00:00 A.M. and 11:59:59 P.M., inclusive. If the time specified by the three arguments, either directly or by expression, falls outside the acceptable range of times, an error occurs.

hour is a number between 0 (12:00 A.M.) and 23 (11:00 P.M.), inclusive, or a numeric expression.

minute is a number between 0 and 59, inclusive, or a numeric expression.

second is a number between 0 and 59, inclusive, or a numeric expression.

Examples

TimeSerial (15,3,24)        returns 3:03:24 PM 
TimeSerial (11,-5,24)       returns 11:55:24 AM
TimeSerial (10,39-5,43)     returns 10:34:43 AM

VBA Code

Dim MyTime As Date
MyTime = TimeSerial(15,3,24)

This example uses the TimeSerial function to return a time for the specified hour, minute, and second. Now the MyTime variable would contain the value of ‘3.03.24 PM’.

SQL query

You can also use the TimeSerial function in a query.

SELECT TimeSerial(10,48,21) AS Expr1 
FROM Orders
admin

admin

Leave a Reply

Your email address will not be published.