Full Version: Time.. Hours.. Minutes.. Seconds.. Milliseconds?
UtterAccess Discussion Forums > Microsoft® Office > Microsoft Excel
Is there a way to format a time with milliseconds? I am working on a project for a friend with racing and he wants his lap times with milliseconds because many of the times are very close.. Seems silly but I can't seem to find it.. perhaps I am just supposed to construct it and decontruct if I want to perform any math on them?
To get down to the milliseconds, I use an API call ...

Public Declare Function GetTickCount Lib "kernel32" () As Long

When called in code, the fuction will return the number of Milleseconds the computer has been ON as a LONG INTEGER.

So to get an elapsed time ... you would need the TickCount from when the race began and the TickCount of when the competitor finished. Note that in SOME circumstances you may need "Rollover" protection.
In addition to what Brent said, if you're speaking about a cell format, try custom format
Try the following code , which like Brent uses an API call, but also has subroutines for 'StartINg' and 'Stopping' with the 'STOP calculating the elapsed time in millisecs.
Public Declare Function adh_apiGetTime Lib "winmm.dll" _
            Alias "timeGetTime" () As Long
Global lngStartTime As Long
Sub adhStartTimer()
    ' Start the timer, storing the value in
    ' the module global, lngStartTime.
    lngStartTime = adh_apiGetTime()
End Sub
Function adhEndTimer() as Long
    ' End timing, and return the difference between the
    ' current time and lngStartTime
    adhEndTimer = adh_apiGetTime() - lngStartTime
End Function
Sorry, wasn't referring to timing with my computer. I pull the data from the racetrack they provide us with actual times I just put them into excel.. I'm really just referring to the formatting.
Thanks everyone,
CB, Does the format I posted above work for you then?
Hi CB,
emember Martin uses European Regional settings, so you may need to change the format to
(sorry to jump in Martin)
Hey, didn't I make a statement on how I like the variety of the WRS recently? link
Thanks Stu sad.gif
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.