Time Between Two Times: How to Calculate It
The calculator for this page is switched off while it is checked. The formula is below, and the worked example in the article shows how to use it by hand.
This calculator works out the duration between two times of day, such as 9:30 AM to 5:45 PM, and returns the result as hours and minutes. You enter the start time and end time, and the calculator gives you the elapsed time in hours, minutes, and as a decimal number of hours. It also handles cases where the end time is on the next day, like a shift from 10:00 PM to 6:00 AM.
Formula
The calculator converts each time to minutes after midnight, subtracts the start from the end, and if the result is negative (meaning the end time is on the next day), it adds 1440 minutes (24 hours). The formula is:
Duration (minutes) = (End time in minutes − Start time in minutes + 1440) mod 1440
Where:
- Start time in minutes = hours × 60 + minutes (e.g., 9:30 AM = 570)
- End time in minutes = hours × 60 + minutes (e.g., 5:45 PM = 1065)
- 1440 = number of minutes in a day
- mod means remainder after division (e.g., 495 mod 1440 = 495)
Worked Example
Using the default values: start at 9:30 AM and end at 5:45 PM.
- Convert 9:30 AM to minutes: 9 × 60 + 30 = 570
- Convert 5:45 PM to minutes: 17 × 60 + 45 = 1065
- Subtract: 1065 − 570 = 495 minutes
- Since 495 is not negative, no adjustment is needed.
- Convert to hours and minutes: 495 ÷ 60 = 8 hours and 15 minutes (since 8 × 60 = 480, remainder 15).
The result is 8 hours 15 minutes, or 8.25 decimal hours. The calculator shows the same.
When to Use This Calculation
You might need the time between two times for:
- Calculating work hours for a timesheet (e.g., 9:00 AM to 5:00 PM = 8 hours).
- Finding the duration of an event, class, or appointment.
- Planning travel time or cooking time that crosses noon or midnight.
- Computing elapsed time for a process that starts in the evening and ends in the morning.
Handling Overnight and 24-Hour Times
If the end time is earlier than the start time, the calculator assumes the end time is on the next day. For example, from 10:00 PM to 6:00 AM:
- 10:00 PM = 1320 minutes, 6:00 AM = 360 minutes
- 360 − 1320 = −960, add 1440 = 480 minutes = 8 hours.
This works for any overnight span up to 24 hours. If you need the exact time across multiple days (e.g., from Monday 9 AM to Wednesday 5 PM), you must add the full days separately. The calculator only handles two times within a 24-hour window.
Common Mistakes and How to Avoid Them
- Mixing AM/PM incorrectly: Always convert PM times to 24-hour format (e.g., 3:00 PM = 15:00). Forgetting to add 12 to PM hours is the most common error.
- Using decimal hours incorrectly: 1.5 hours is 1 hour 30 minutes, not 1 hour 50 minutes. To convert decimal hours to minutes, multiply the fractional part by 60.
- Ignoring overnight: If you subtract a later time from an earlier time without adding 1440, you get a negative number. Always check if the end is after the start.
- Rounding too early: Keep the result in minutes until the final step to avoid rounding errors.
Limitations of the Formula
This formula assumes a 24-hour day and ignores time zones, daylight saving changes, and leap seconds. For most everyday uses, those factors are irrelevant. If you are calculating across a daylight saving time change (e.g., in spring or autumn), the actual elapsed time may be 23 or 25 hours, not 24. The calculator does not account for that; it simply uses the clock times you enter.
Frequently Asked Questions
How do I calculate time between two times in Excel?
In Excel, you can subtract the start time from the end time if both are formatted as times. For example, if A1 is 9:30 and B1 is 17:45, the formula =B1-A1 gives 8:15. If the end time is on the next day, use =B1-A1+(B1<A1) to add 1 day when needed. Format the result as [h]:mm to show total hours.
What does “duration” mean in decimal hours?
Decimal hours express the duration as a fraction of an hour. For example, 8 hours 15 minutes is 8.25 hours because 15 minutes is 0.25 of an hour (15/60). This is often used in payroll or billing systems.
Can I calculate the time between two times that are more than 24 hours apart?
No, this calculator only works for two times within a 24-hour cycle. For longer durations, you would need to add the number of full days separately. For instance, from Monday 9 AM to Wednesday 5 PM is 2 days (48 hours) plus 8 hours = 56 hours.
Why do I get a negative number when I subtract times?
You get a negative number when the end time is earlier than the start time, which usually means the end time is on the next day. Adding 1440 minutes (24 hours) corrects this. For example, 6:00 AM minus 10:00 PM is -960 minutes; adding 1440 gives 480 minutes, or 8 hours.
How do I convert minutes to hours and minutes?
Divide the total minutes by 60. The whole number is the hours, and the remainder is the minutes. For example, 495 minutes divided by 60 is 8 with a remainder of 15, so it’s 8 hours 15 minutes.
Related
Formula used
in t1 | Start time (HH:MM) | - | 9:30 | 0 in t2 | End time (HH:MM) | - | 17:45 | 0 out dur | Duration | h:mm | ((t2 - t1) + 1440) % 1440 | time out dec | Duration in decimal hours | h | ((t2 - t1) + 1440) % 1440 / 60 | 2
Each line is one input (in, sel, list) or one result (out: label, unit, formula, decimals). How the calculators work
Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.