Share via

Calculate the difference between two times in Access

Anonymous
2015-10-06T20:08:04+00:00

I am creating a report and I need a field that calculates the difference between the start and stop times.  I.E., I want the field to subtract the stop time from the start time and return the decimal of an hour.  See below

[stop] 10:00 - [start] 09:30 = 0.50 

Is this possible.  I did it once in Excel, but I needed 2 calculations (one to get the difference and one to round it using ceiling), but I am hoping there is a way to do it in a single calculation.

I tried simply subtracting the time and somehow got 0.21 as the answer for the above.

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

3 answers

Sort by: Most helpful
  1. Anonymous
    2015-10-06T20:33:25+00:00

    You need TWO fields in your table that both are DateTime datatype.

    Then in a query use  --  (DateDiff("n",[Start],[Stop])\6)/10  

    DateDiff give the difference in minutes,  \6 divides by 6 giving an integer, which is then Divided by 10.

    10+ people found this answer helpful.
    0 comments No comments
  2. ScottGem 68,810 Reputation points Volunteer Moderator
    2015-10-08T17:39:38+00:00

    Does the elapsed time ever span more than 24 hours? If it doesn't then you should be fine. If it does, however, then you need to include the date as well as the time. 

    You need to understand that Access stores time as a double precision number where the integer portion is the number of days since 12/30/1899 and the decimal portion a fraction of a day. So that .25 would be 6 AM (or 6 hours).

    If you use this:

    =(Stoptime - Starttime)*24 it should also work. 

    To use your numbers 10:00-09:30 would = 0.0208333. Multiple that by 24 and you get .49999992

    10+ people found this answer helpful.
    0 comments No comments
  3. Anonymous
    2015-10-08T15:29:43+00:00

    Perfect!!!  I was trying to do this, but for some reason I couldn't get it right.  I think it was the \6 and/10 that was giving me trouble.  I appreciate the help.

    1 person found this answer helpful.
    0 comments No comments