Applies ToAccess for Microsoft 365 Access 2024 Access 2021 Access 2019 Access 2016

Returns a Single representing the number of seconds elapsed since midnight.

Syntax

Timer

Remarks

In Microsoft Windows the Timer function returns fractional portions of a second. On the Macintosh, timer resolution is one second.

Query example

Expression

Results

SELECT Timer() AS SecondsPast FROM ProductSales GROUP BY Timer();

Returns the number of seconds elapsed since midnight based on the system time and displays in the column SecondsPast.

VBA example

Note: Examples that follow demonstrate the use of this function in a Visual Basic for Applications (VBA) module. For more information about working with VBA, select Developer Reference in the drop-down list next to Search and enter one or more terms in the search box.

This example uses the Timer function to pause the application. The example also uses DoEvents to yield to other processes during the pause.

Dim PauseTime, Start, Finish, TotalTimeIf (MsgBox("Press Yes to pause for 5 seconds", _        4)) = vbYes Then    PauseTime = 5    ' Set duration.    Start = Timer    ' Set start time.    Do While Timer < Start + PauseTime        DoEvents    ' Yield to other processes.    Loop    Finish = Timer    ' Set end time.    TotalTime = Finish - Start  ' Calculate total time.    MsgBox "Paused for " & TotalTime & " seconds"Else    EndEnd If

Choose the right date function

Need more help?

Want more options?

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.