help with date/time interval

  • Thread starter Thread starter Access
  • Start date Start date
A

Access

HI

Here is what I have

[etime1] = date. ex 10/31/03
[etime2] = time. ex 14:10

I need to calculate the time interval between now() and the future date/time
and get the results in hh:nn (hours/minutes). Like this:

now() - [etime1]&" "&[etime2] = 600:25

but how can I do it....

HELP!
 
Date and times are stored as number: 8 byte floating point numbers, to be
precise, where the integer part represents the date as the number of days
relative to 30 Dec, 1899, and the decimal part represents the time as a
fraction of day. Therefore, you can add dates and times together.

Using the DateDiff function is the best way to calculate differences between
dates/times.

DateDiff("n", Now(), [etime1] + [etime2]) will give you the number of
minutes until the future date/time. You're probably best off writing a
function to convert minutes to hh:nn. Something like the following untested
air-code:

Function FormatMinutes(TimeInMinutes As Long) As String

FormatMinutes = TimeInMinutes \ 60 & ":" & _
Format$(TimeInMinutes Mod 60, "00")

End Function
 
Back
Top