Duration 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 exact duration between two times of day, in hours and minutes, and also shows the total in minutes. You enter a start time and an end time, choose whether the end is on the same day or the next day, and you get the elapsed time as your main answer. The result is given as h:mm:ss, which makes it easy to use for shift planning, travel time, or any schedule math.
Formula
The core formula is simple: convert both times to minutes after midnight, then subtract the start from the end. If the end time is on the next day, add 24 hours (1440 minutes) to the result.
In symbols: Duration (minutes) = End (minutes) – Start (minutes) + 1440 × Overnight
- Start – the earlier time, in 24-hour or 12-hour format, converted to minutes since midnight.
- End – the later time, also converted to minutes since midnight.
- Overnight – 0 if the end is on the same day, 1 if the end is on the next day.
For example, 9:00 AM becomes 9 × 60 = 540 minutes. 5:30 PM (17:30) becomes 17 × 60 + 30 = 1050 minutes.
Worked Example
Using the default values: start at 09:00, end at 17:30, same day.
- Convert start: 09:00 → 9 × 60 = 540 minutes
- Convert end: 17:30 → 17 × 60 + 30 = 1050 minutes
- Subtract: 1050 – 540 = 510 minutes
- Overnight flag is 0, so no extra addition.
- Convert to h:mm:ss: 510 minutes = 8 hours and 30 minutes, i.e. 8:30:00
The calculator shows 8:30:00 as the headline result, and 510 minutes as the total. That matches the manual calculation.
When to Use This Calculation
You need this whenever you must know the exact span between two clock times, not just a rough guess. Common situations include:
- Calculating work hours for a shift that starts and ends at specific times.
- Measuring travel time between departure and arrival.
- Estimating how long a meeting, class, or event will last.
- Determining the duration of a video or audio file given start and end timestamps.
- Figuring out how much time remains before a deadline (e.g., from 2:15 PM to 5:00 PM).
The result is most useful when you need a precise number, such as for payroll (hours worked) or for scheduling. For rough estimates, you might round to the nearest quarter-hour, but the calculator gives the exact figure.
How to Read the Result
The main output is shown as h:mm:ss. For example, 8:30:00 means 8 hours, 30 minutes, and 0 seconds. If the duration is less than an hour, it will show something like 0:45:00 (45 minutes). The secondary output gives the same duration in total minutes, which is handy for multiplying by an hourly rate or comparing with other time spans.
If you set the “Overnight?� option to “Yes,� the calculator adds 24 hours to the end time. This is correct for shifts that start at 10:00 PM and end at 6:00 AM the next day: the duration is 8 hours, not a negative number. Without the overnight flag, the formula would produce a negative result, which is meaningless for elapsed time.
Common Mistakes and How to Avoid Them
- Forgetting the overnight flag – If you have a shift from 11 PM to 7 AM, you must select “Yes� for overnight. Otherwise, you get -16 hours, which is incorrect.
- Mixing 12-hour and 24-hour formats – If you enter 5:30 for 5:30 PM, the calculator treats it as 5:30 AM. Always use 24-hour time (e.g., 17:30) or be consistent with AM/PM if your input allows it.
- Rounding too early – If you round each time to the nearest hour, you can introduce errors. For instance, 9:20 to 10:45 is 1 hour 25 minutes, but rounding to 9 and 11 gives 2 hours.
- Ignoring seconds – If your times include seconds, the calculator supports them (e.g., 09:15:30). If you omit seconds, they default to 00, which is fine for most uses.
Limitations and Edge Cases
This calculation assumes a 24-hour day and does not account for time zones, daylight saving time changes, or leap seconds. If your start and end times are in different time zones, you must first convert them to a common time zone. For example, a flight from New York (EST) to London (GMT) crosses time zones; the duration is the difference in UTC times, not local times.
Another edge case: if the start and end are exactly the same, the duration is 0. If the end is earlier than the start and you do not mark it as overnight, the result will be negative. The calculator does not automatically flip the sign, so you must decide whether the end is on the next day.
For durations longer than 24 hours, you would need to add multiples of 1440 minutes. This calculator is designed for single-day spans (up to 24 hours). For multi-day events, sum the daily durations separately.
Alternative Methods
You can also calculate duration manually using these steps:
- Write both times in 24-hour format.
- Convert each to minutes: hours × 60 + minutes.
- Subtract start from end. If negative, add 1440.
- Convert the result back to hours and minutes.
Or use a spreadsheet: put start in cell A1, end in B1, and in C1 type =B1-A1 and format as time. This works because spreadsheet time values are fractions of a day. For overnight, add 1 to the end time (e.g., =B1+1-A1).
For quick mental math, break the duration into parts: from 9:00 to 12:00 is 3 hours, from 12:00 to 17:30 is 5 hours 30 minutes, total 8 hours 30 minutes. This works well when the start and end are on clean hour boundaries.
Frequently Asked Questions
How do I calculate the duration between two times in Excel?
In Excel, enter the start time in cell A1 and the end time in B1. In C1, type =B1-A1 and format C1 as “h:mm�. If the end is on the next day, use =B1+1-A1. Excel stores times as fractions of a day, so 0.5 represents 12:00 PM. The result will be a decimal that you format as time.
What is the formula for time duration in Google Sheets?
Google Sheets works the same way as Excel. Use =B1-A1 and format the result as duration (Format → Number → Duration). For overnight, add 1 to the end time. The result will display as hours and minutes, and you can also sum multiple durations.
How do I calculate minutes between two times?
Convert both times to minutes since midnight, subtract the start from the end, and if the end is earlier, add 1440. For example, 9:30 AM to 2:15 PM: 9:30 = 570 minutes, 2:15 PM = 855 minutes, difference = 285 minutes (4 hours 45 minutes).
What is the difference between elapsed time and duration?
They are essentially the same. Elapsed time is the amount of time that passes from a start event to an end event. Duration is the length of that interval. Both are measured in seconds, minutes, hours, etc. In everyday language, you might say “the duration of the movie is 2 hours� or “the elapsed time was 2 hours.�
How do I handle times that cross midnight?
Add 24 hours (1440 minutes) to the end time before subtracting the start. For example, 11:00 PM to 2:00 AM: 11 PM = 1380 minutes, 2 AM = 120 minutes, but since 120 < 1380, add 1440 to 120 to get 1560, then subtract 1380 = 180 minutes (3 hours).
Can I calculate duration with seconds included?
Yes. Use the format HH:MM:SS in the input, and the calculator will handle seconds. The result will show seconds as well. For example, 09:15:30 to 10:45:45 gives 1 hour, 30 minutes, 15 seconds. If you omit seconds, they are treated as zero.
Related
Formula used
in t | Start time (HH:MM) | - | 09:00 | 0 in d | End time (HH:MM) | - | 17:30 | 0 in o | Overnight? (end next day) | No=0, Yes=1 | 0 | 0 out dur | Duration | h:mm:ss | (d - t + o*1440) | time out mins | Total minutes | min | (d - t + o*1440) | 0
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.