午前 0 時 (真夜中) から経過した秒数を単精度浮動小数点数型 (Single) で返します。
構文
タイマー
解説
Microsoft Windows では 、Timer 関数 は秒の小数部を返します。 Macintosh では、タイマーの解像度は 1 秒です。
クエリの例
式 |
結果 |
SELECT Timer() AS SecondsPast FROM ProductSales GROUP BY Timer(); |
システム時刻に基づいて午前 0 時以降に経過した秒の数を返し、列 SecondsPast に表示します。 |
VBA の例
注: 次の例は、Visual Basic for Applications (VBA) モジュールでのこの関数の使用方法を示しています。 VBA の使用方法の詳細については、[検索] の横にあるドロップダウン リストで [開発者用リファレンス] を選び、検索ボックスに検索する用語を入力します。
この例では 、Timer 関数を 使用してアプリケーションを一時停止します。 この例では 、DoEvents を使用して 、一時停止中に他のプロセスに回り込む場合も使用します。
Dim PauseTime, Start, Finish, TotalTime
If (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
End
End If