Time calculation

  • Thread starter Thread starter Pitbull
  • Start date Start date
P

Pitbull

Guest
Can anyone tell me the formula to calculate the difference between two times. For example, I want to know the time between 10:15 AM and 1:15 PM. I have the times entered in two different fields. Thanks.

I need a better clue than indicated below. Can you suggest an expression?

:confused:
 
Last edited:
Check out the DateDiff function in Access Help.
 
The clue, as given, was correct. My concern is, are your times are by themselves or do they occur with dates?

That is, you have 10:15 AM in a field. Is this time in a date/time field or a text field? Is there a date to go with it?

The way I would do this involves forming a complete date/time sequence. Let's say that you have four fields that are strings, with the date and time for moment T0 and the date and time for moment T1.

First, I would form expressions for the combined date/time, as

CDate( Date_T0 & " " & Time_T0)
CDate( Date_T1 & " " & Time_T1)

Then I would use the DateDiff function to get units of SECONDS between T0 and T1. The hint to look at the help files is quite specific. You should not discount it.

Once you have the time in seconds, you can do nearly anything you want to reformat the interval.

If you have the dates and times in other types of fields, you might be making extra trouble for yourself - unless the actual T0 and T1 are already combined in a Date/Time field, in which case you don't need a conversion function.
 

Users who are viewing this thread

Back
Top Bottom