• Status: Solved
• Priority: Medium
• Security: Public
• Views: 152

Compute Elapsed TIme to 1/10th or 1/00th of a second

I'm experiencing some slow processing with an app when it runs in Access 2013.  Versions prior to 2013 are fine.  To find the bottleneck I want to put a timing log in the app.  I have a routine that will calculate the difference between two times down to the second but I need to me more granular than that to find out where my bottleneck is:  Does anyone have a routine that will calculate the difference between two times to a 10th or even 100th of a second?

Here's my current routine used to post processing information on the screen for long running processes:

``````Public Function RunTime(passedStartTime As Date, passedCurrTime As Date) As String
'
Dim lngHours As Long
Dim lngSeconds As Long
Dim lngMinutes As Long
Dim txtSeconds As Long
Dim txtMinutes As Long

lngSeconds = DateDiff("s", passedStartTime, passedCurrTime)
'
lngHours = Int(lngSeconds / 3600)
lngSeconds = lngSeconds - (lngHours * 3600)
lngMinutes = Int(lngSeconds / 60)
lngSeconds = lngSeconds - (lngMinutes * 60)
'
txtMinutes = Trim(Str(lngMinutes))
txtSeconds = Trim(Str(lngSeconds))
'
RunTime = "Elapsed Time = " & lngHours & " Hour(s), " & txtMinutes & " Minute(s) and " & txtSeconds & " Second(s)"
'

End Function
``````

It returns a string (xx Hours, xx Minutes, xx Seconds).  I would like to go to the 1/10th or 100/th of a second difference
0
mlcktmguy
1 Solution

Commented:
try using the Cdbl() function

cdbl(passedCurrTime) - cdbl(passedStartTime)

the first thre digit after the . (period) gives you the hour and minutes, the fourth digit to te end is your second/milliseconds
0

CIOCommented:
You can use function Timer to get the count of seconds from Midnight with 1/18 second resolution.

/gustav
0

Author Commented:
This Timer was granular enough to track differences as the code executed.  In many case the Cdbl approach calculated a time difference of 0 between steps.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.