help with date/time interval

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!
 
D

Douglas J. Steele

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
 

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