Time Calculation(s)

  • Thread starter Thread starter Anthony Viscomi
  • Start date Start date
A

Anthony Viscomi

I am trying to display the elaspsed time that it for a loop that contains
Update Queries. I have the following:

Dim Starttime as Date

StartTime = Now

(performs updates)

MsgBox "Total Time Taken: " & Now - StartTime

The result of the above message is somethimg like this:
X.XXXXXXE-X.X

From what I can gather from the Help on Date this number represents IEEE
64-bit (8-byte) floating-point numbers. Is there a conversion for this?

Thanks,
Anthony
 
You could just use the 'Timer' which gives its results in seconds (and
fractions of a second).

e.g.

Sub CheckTime()

Dim Start As Single
Dim i As Integer

Start = Timer
For i = 1 To 10000
DoEvents
Next

MsgBox "Time taken = " & Timer - Start
End Sub

Cheers,
Peter
 
I am trying to display the elaspsed time that it for a loop that contains
Update Queries. I have the following:

Dim Starttime as Date

StartTime = Now

(performs updates)

MsgBox "Total Time Taken: " & Now - StartTime

The result of the above message is somethimg like this:
X.XXXXXXE-X.X

From what I can gather from the Help on Date this number represents IEEE
64-bit (8-byte) floating-point numbers. Is there a conversion for this?

A Date/TIme value is a Double Float count of days and fractions of a
day - so the "total time taken" will be in days.

I'd suggest using the DateDiff() function to calculate the time
differential. If you want it in seconds, use

MsgBox "Total Time Taken: " & DateDiff("s", StartTime, Now)

Date/Times don't allow for display at a finer resolution than integer
seconds, so if you want seconds and fractions of a second, use the
Timer function instead as noted elsethread.
 
Thanks to all!
John Vinson said:
A Date/TIme value is a Double Float count of days and fractions of a
day - so the "total time taken" will be in days.

I'd suggest using the DateDiff() function to calculate the time
differential. If you want it in seconds, use

MsgBox "Total Time Taken: " & DateDiff("s", StartTime, Now)

Date/Times don't allow for display at a finer resolution than integer
seconds, so if you want seconds and fractions of a second, use the
Timer function instead as noted elsethread.
 
Back
Top