totn Access Functions

MS Access: TimeSerial Function

This MSAccess tutorial explains how to use the Access TimeSerial function with syntax and examples.

Description

The Microsoft Access TimeSerial function returns a time given an hour, minute, and second value.

Syntax

The syntax for the TimeSerial function in MS Access is:

TimeSerial ( hour, minute, second )

Parameters or Arguments

hour
A numeric value between 0 and 23 that represents the hour value of the time.
minute
A numeric value that represents the minute value of the time.
second
A numeric value that represents the second value of the time.

Returns

The TimeSerial function returns a time value.

Applies To

The TimeSerial function can be used in the following versions of Microsoft Access:

  • Access 2019, Access 2016, Access 2013, Access 2010, Access 2007, Access 2003, Access XP, Access 2000

Example

Let's look at how to use the TimeSerial function in MS Access:

TimeSerial (14, 6, 30)
Result: 2:06:30 PM

TimeSerial (20 - 8, 6, 30)
Result: 12:06:30 PM

TimeSerial (8, 6-2, 14)
Result: 8:04:14 AM

TimeSerial (7, -15, 50)
Result: 6:45:50 AM

Example in VBA Code

The TimeSerial function can be used in VBA code in Microsoft Access.

For example:

Dim LTime As Date

LTime = TimeSerial (23, 5, 31)

In this example, the variable called LTime would now contain the value of '11:05:31 PM'.

Example in SQL/Queries

You can also use the TimeSerial function in a query in Microsoft Access.

For example:

Microsoft Access

In this query, we have used the TimeSerial function as follows:

Expr1: TimeSerial(16,3,58)

This query will calculate a time value based on 16 as the hour, 3 as the minutes, and 58 as the seconds. The results will be displayed in a column called Expr1. You can replace Expr1 with a column name that is more meaningful.

For example:

TimeValue: TimeSerial(16,3,58)

The results would now be displayed in a column called TimeValue.