Count overlapping time once, and never count the gaps
Add 9:00 AM – 12:00 PM and 11:00 AM – 2:00 PM as they stand and you get 6 hours. But 11:00 AM – 12:00 PM appears in both entries, so it was counted twice. Count that hour once and the two entries actually cover 9:00 AM – 2:00 PM, which is 5 hours. In math this is the length of the union of the intervals.
The example on the calculator's first screen has four ranges: 9:00 AM – 12:00 PM, 11:00 AM – 2:00 PM, 1:30 PM – 3:00 PM and 4:00 PM – 5:30 PM. Added up, they come to 9 hours, but 11:00 AM – 12:00 PM and 1:30 PM – 2:00 PM overlap, so 1 hour 30 minutes was counted twice. The total without overlap is 7 hours 30 minutes. And because nothing covers 3:00 PM – 4:00 PM, it is also different from the 8 hours 30 minutes between the first start and the last end. On the timeline, the hatching on a bar marks the part that was counted twice, and the breaks in the “Merged result” row at the bottom are the gaps.
When you need to take overlaps out
When several records occupy the same stretch of time, how you add them depends on the question you are asking. If you want to know how many hours of the period were actually filled, overlapping time has to be counted once.
- Room or equipment usage: even if bookings overlap, the room is only in use for one stretch of time. To get daily utilization, divide the total without overlap by the hours the room is open.
- Work or study logged in more than one app: if a timer app and a calendar both recorded the same hour, a plain sum comes out longer than reality. The overlap list shows which entries are duplicates.
- Care or on-call schedules that must have no gaps: when several people split a shift, the gaps are exactly the time nobody is covering. In the first-screen example, 3:00 PM – 4:00 PM is a gap.
- Merging call, video or login records: records that ran at the same time become one period of use. You also get the highest number running at once, and when that happened.
The opposite case: if two people each work one hour at the same time, the workload is 2 person-hours. To add up the time each person put in, don't remove the overlap. Use the “Simple total” in the result instead.
How it is calculated
- Convert times to minutes. 9:30 AM is 9 × 60 + 30 = 570 minutes. After that, a range's length is just the end minus the start.
- If the end is earlier than the start, add a day. 10:00 PM – 2:00 AM is 120 + 1,440 − 1,320 = 240 minutes, or 4 hours. An end of 12:00 AM counts as the end of that day, 24:00.
- Cut the time axis at every boundary. Line up all the starts and ends in order, then count how many ranges cover each piece between them.
- Add up every piece that at least one range covers. That is the total without overlap. Adding only the pieces covered by two or more gives the overlapping time.
- Work out the time counted twice. A piece covered by k ranges went into the simple total k times, so k − 1 of them must come out. The sum of these is the “counted twice” time, and it equals the simple total minus the total without overlap.
Total = Σ piece length (k ≥ 1) · Counted twice = Σ (k − 1) × piece length = simple total − total
A point where one range ends exactly as another begins has no length, so it is not an overlap. 9:00 AM – 12:00 PM and 12:00 PM – 2:00 PM show as one block, 9:00 AM – 2:00 PM, in the merged result, and the time counted twice is 0 minutes.
The 13 ways two ranges can sit
Any two time intervals stand in exactly one of the 13 relations catalogued by Allen (1983): six pairs (before and after, meets and is met by, overlaps and is overlapped by, starts and is started by, during and contains, finishes and is finished by) plus “equals”. The W3C Time Ontology defines the same 13, plus two grouped relations (intervalIn and intervalDisjoint). The two halves of a pair just swap which range is A and which is B, and the result is the same, so the table below shows only the 7 cases where B is added to A = 9:00 AM – 12:00 PM.
| Relation | B | Counted twice | Total | |
|---|---|---|---|---|
| Before (with a gap) | 1:00 PM – 2:00 PM | 0 min | 4 h | Try it |
| Meets (touching) | 12:00 PM – 2:00 PM | 0 min | 5 h | Try it |
| Overlaps | 11:00 AM – 2:00 PM | 1 h | 5 h | Try it |
| Starts together | 9:00 AM – 10:00 AM | 1 h | 3 h | Try it |
| During (inside A) | 10:00 AM – 11:00 AM | 1 h | 3 h | Try it |
| Finishes together | 11:00 AM – 12:00 PM | 1 h | 3 h | Try it |
| Equals | 9:00 AM – 12:00 PM | 3 h | 3 h | Try it |
When B sits completely inside A, adding more ranges like B leaves the total at 3 hours. Entering the same record twice (“Equals”) takes the full 3 hours off the simple total of 6.
With three ranges, the time counted twice gets longer
9:00 AM – 12:00 PM, 10:00 AM – 1:00 PM and 11:00 AM – 2:00 PM are 3 hours each, so the simple total is 9 hours, and the merged range is 9:00 AM – 2:00 PM, or 5 hours. The time covered by two or more ranges is 10:00 AM – 1:00 PM, which is 3 hours, yet the time counted twice is 4 hours. That is because 11:00 AM – 12:00 PM is covered by all three ranges and was added three times, so two of them have to come out. Splitting the timeline into pieces, as in the table below, makes the difference visible.
| Piece | Ranges covering it | Time in the simple total | Time to remove |
|---|---|---|---|
| 9:00 AM – 10:00 AM | 1 | 1 h | 0 min |
| 10:00 AM – 11:00 AM | 2 | 2 h | 1 h |
| 11:00 AM – 12:00 PM | 3 | 3 h | 2 h |
| 12:00 PM – 1:00 PM | 2 | 2 h | 1 h |
| 1:00 PM – 2:00 PM | 1 | 1 h | 0 min |
| Total | 9 h | 4 h |
This is the inclusion–exclusion principle at work. The union of three sets A, B and C is A + B + C, minus the pairwise overlaps (A∩B, B∩C, A∩C), plus the triple overlap (A∩B∩C) added back. That gives 9 − (2 + 2 + 1) + 1 = 5 hours, the same answer. The “Overlap depth” row on the calculator's timeline draws these per-piece counts as stair steps.
Records that cross midnight, and multi-day records
If the end time is earlier than the start, the calculation treats it as ending the next day. 10:00 PM – 2:00 AM is 4 hours without any extra step, and the length column adds “ends next day”. The trouble comes with records that start after midnight. If you simply enter 1:00 AM – 3:00 AM from the same night, it is read as 1:00 AM on the first day and does not overlap 10:00 PM – 2:00 AM.
| Input | Total | Counted twice | |
|---|---|---|---|
| Day 1 10:00 PM – 2:00 AM · Day 2 1:00 AM – 3:00 AM | 5 h | 1 h | Try it |
| Day 1 10:00 PM – 2:00 AM · Day 1 1:00 AM – 3:00 AM | 6 h | 0 min | Try it |
| 9:00 AM – 9:00 AM · Count as 24 h | 24 h | 0 min | Try it |
When a range starts after midnight, switch on “Multi-day” above the timeline and set that range's start day to Day 2. Start days run from Day 1 to Day 7, so a multi-day shift or event can be merged in one go. If the start and end are the same time, the calculator stops, because it cannot tell a 0-minute record from a full day. For something like a 24-hour shift that ended at the same time the next day, press “Count as 24 h” on that row.
Getting the same number in Excel or a spreadsheet
If your records are already in a table, sort them by start time and keep a running column of the latest end so far. Each row then adds only the part that extends past that end. Suppose starts are in column A and ends in column B, beginning on row 2. The formulas are:
| Column | Meaning | Row 2 | Row 3 onward (fill down) |
|---|---|---|---|
| C | End, corrected for midnight | =IF(B2<A2,B2+1,B2) | =IF(B3<A3,B3+1,B3) |
| D | Latest end so far | =C2 | =MAX(D2,C3) |
| E | Newly added time | =C2-A2 | =MAX(0,C3-MAX(A3,D2)) |
The sum of column E is the total without overlap. Excel treats one day as 1, so B + 1 is the same time on the next day. Set the number format of the total cell to [h]:mm and it shows hours and minutes, like 7:30, without rolling over to 0 after 24 hours. With the first-screen example:
| Row | A Start | B End | D Latest end | E Newly added |
|---|---|---|---|---|
| 2 | 9:00 | 12:00 | 12:00 | 3:00 |
| 3 | 11:00 | 14:00 | 14:00 | 2:00 |
| 4 | 13:30 | 15:00 | 15:00 | 1:00 |
| 5 | 16:00 | 17:30 | 17:30 | 1:30 |
| Total | 7:30 |
Skip the sort and the end of an earlier row can be later than a following row's, which throws the result off, so sort column A in ascending order first. For records that span several dates, put the date and time together in columns A and B and the same formulas work without the correction in column C.
Common mistakes
- Using first start to last end as the total: 9:00 AM – 12:00 PM and 1:00 PM – 2:00 PM come to 4 hours. Calculating 9:00 AM – 2:00 PM as 5 hours includes 12:00 PM – 1:00 PM, when nothing was recorded.
- Using the simple total as is: when records overlap, plain addition is longer than reality. If the time counted twice in the result is not 0 minutes, check which records overlap first.
- Treating touching ranges as overlapping: two records, one ending at 12:00 PM and the other starting at 12:00 PM, share not a single minute.
- Entering a break as a new range: to remove a 12:00 PM – 1:00 PM lunch from 9:00 AM – 6:00 PM, adding the lunch as another row actually creates an overlap. Enter two rows instead, 9:00 AM – 12:00 PM and 1:00 PM – 6:00 PM.
- Reading decimal hours as hours and minutes: 7.5 hours is 7 hours 30 minutes, not 7 hours 50. When moving the figure to another table, the unrounded minutes (450) are the safer value.
Limits and cautions
- Times are in 1-minute steps, and you can enter up to 20 ranges. Round second-level records to the minute.
- A single range cannot exceed 24 hours. Split a longer record across days into two rows. Start days go up to Day 7.
- A day is always taken as 24 hours. Records from a daylight saving changeover day, or from different time zones, need to be converted to one time zone first.
- The result is only the length of the ranges you entered. It is not a basis for counting working hours or breaks, or for working out pay or fees. Check the rules that apply to those calculations separately.
- Everything is calculated inside this browser and nothing is sent to a server. The ranges go into the address only when you press “Copy link”.
Sources
- 01Allen, J. F. (1983). Maintaining knowledge about temporal intervals. Communications of the ACM, 26(11), 832–843The 13 relations between two time intervals (before, meets, overlaps, starts, during, finishes, equals and their inverses)
- 02W3C Time Ontology in OWL, 3.1 Topological Temporal RelationsCandidate Recommendation Draft, 2022-11-15; defines Allen's 13 interval relations as intervalMeets, intervalOverlaps and so on
- 03Microsoft Support: Format numbers as dates or timesThe elapsed-time format code [h]:mm
- 04NIST SP 811, Chapter 5: Units Outside the SITable 6: 1 min = 60 s, 1 h = 60 min, 1 d = 24 h
- 05WHATWG HTML Standard: Time state (type=time)The input value is a 24-hour “hh:mm” string; the on-screen format may follow the device's settings
Frequently asked questions
How many hours is 9:00 AM – 12:00 PM plus 11:00 AM – 2:00 PM?
For records on the same day, the total without overlap is 5 hours. Adding the two ranges directly gives a simple total of 6 hours, and the 1 hour from 11:00 AM to 12:00 PM was counted twice, so it comes out.
What is the difference between double-counted time and overlapping time?
Overlapping time is the length of time covered by two or more ranges. Double-counted time is what has to come off the simple total. For 9:00 AM – 12:00 PM, 10:00 AM – 1:00 PM and 11:00 AM – 2:00 PM, the overlapping time is 3 hours, but 11:00 AM – 12:00 PM was added three times, so the double-counted time is 4 hours.
Do a range ending at 12:00 PM and one starting at 12:00 PM overlap?
No. A shared moment has no length, so 9:00 AM – 12:00 PM and 12:00 PM – 2:00 PM total 5 hours with 0 minutes counted twice. In the merged result they appear as one block from 9:00 AM to 2:00 PM.
How do I enter 10:00 PM to 2:00 AM?
Just enter 10:00 PM and 2:00 AM. When the end is earlier than the start, it is treated as ending the next day, which gives 4 hours. For a record that starts after midnight on the same night, such as 1:00 AM – 3:00 AM, switch on “Multi-day” and set its start day to Day 2.
Is 9:00 AM – 9:00 AM counted as 24 hours?
Not by default. The calculator cannot tell whether it is a 0-minute record or a whole day, so it does not calculate. If the record ended at the same time the next day, press “Count as 24 h” on that row.
Is a gap between ranges included in the total?
No. 9:00 AM – 12:00 PM and 1:00 PM – 2:00 PM total 4 hours, and the 1 hour from 12:00 PM to 1:00 PM is shown separately under “Gaps”. The length from the first start to the last end appears under “First to last”.
Can I get the total without overlap in Excel too?
Yes. Sort by start time, keep a running latest end with MAX, and in each row add only the part past that end with MAX(0, end − MAX(start, previous latest end)). Format the total cell as [h]:mm.
How many ranges can I enter, and are my entries saved?
You can enter up to 20. Everything is calculated inside your browser and nothing is sent to a server. The ranges go into the address only when you press “Copy link”.