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

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

Open in new window

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
1 Solution
Rey Obrero (Capricorn1)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
Gustav BrockCIOCommented:
You can use function Timer to get the count of seconds from Midnight with 1/18 second resolution.

mlcktmguyAuthor 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.
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.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now