Time Calculations

J

Joe

I have two numeric (Long Integer) fields that contain
times in 24 hr. format (HHMMSS).

How can I perform a time calculation to determine the
difference in time between the two? The 2nd time value
may span across midnight. But, both time values will have
occurred within 24 total hours (times never go across more
than one date).
 
G

Guest

I checked the site, but I can't get it to work.

Two fields are: AHTIME (which is the first time, and
might be a value of 227 which would be the same as
00:02:27) ESTIME is the later time and might be, for
example, 010503, which would be the same as 01:05:03.

I want to substract ESTIME from AHTIME to get the amount
of time spent and present the value in this format
00:00:00 or HH:MM:SS.
 
D

Douglas J. Steele

You're going to need to convert your integer values to actual times first,
then you can use the reference Van posted.

The following untested air-code should do the conversion for you

Function ConvertTime(TimeIn As Integer) As Date

Dim strHHNNSS As String

strHHNNSS = Format(TimeIn, "000000")
ConvertTime = TimeSerial(Left$(strHHNNSS, 2), _
Mid$(strHHNNSS, 3, 1), Right$(strHHNNSS, 2))

End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top