How to Calculate Time Difference (Hours & Minutes)

A shift starts at 9:15 PM and ends at 6:00 AM. A meeting spans two time zones. A timesheet needs total hours worked, not just clock-in and clock-out. The moment "how much time passed?" involves an overnight shift or needs to feed into payroll, simple subtraction starts breaking — the result goes negative, or Excel shows a full date-time stamp instead of a clean duration.

Time difference is easy once you match the method to the situation: same-day subtraction, an overnight-safe formula, or a decimal-hours conversion for payroll. This guide walks through each one, the mistakes that trip people up, and which to reach for.

Quick Answer

To find the difference between two times on the same day, subtract the start time from the end time and format the result as time (h:mm). If the shift crosses midnight, use =MOD(B2-A2,1) instead, which automatically adds a day back in so the result doesn't come out negative.

What is a time difference calculation, and what are the options?

"Time difference" usually means one of three things, depending on what happens between the start and end time.

Each approach reads the same two time values; the difference is in how midnight is handled and whether the output needs to look like a clock duration or a plain number.

Why the right method matters

Picking the wrong method for the situation doesn't throw an error — it just quietly hands back a number that looks plausible but is wrong. That shows up in a few common places:

📊 Quick stat Overnight shifts make up a meaningful share of payroll errors in shift-based industries — a single unadjusted midnight crossing can turn an 8-hour shift into a negative duration that most spreadsheets won't flag as wrong on their own.

Step-by-step: calculating time differences

Method 1: Same-day duration (direct subtraction)

  1. Enter both times in separate cells. Store them as real time values, not text — for example, A2 as the start time and B2 as the end time.
  2. Click an empty cell for the result. This is where the duration will appear.
  3. Type the subtraction formula.
    =B2-A2
  4. Format the result cell as Time (h:mm). If it shows a full date-time instead of a short duration, change the cell format to a custom h:mm pattern.

Method 2: Overnight shifts (MOD formula)

  1. Wrap the subtraction in MOD.
    =MOD(B2-A2,1)
  2. Format the result as Time (h:mm). MOD adds a full day back in whenever the end time crosses midnight, so the duration comes out positive and correct either way.

Method 3: Decimal hours for payroll

  1. Multiply the (MOD-corrected) difference by 24.
    =MOD(B2-A2,1)*24
  2. Format the result cell as Number. This converts the fractional day into total decimal hours, like 7.5, which multiplies cleanly against an hourly rate.
Just need one time gap, not a spreadsheet? Rebrixe's free Time Difference Calculator gives the exact result instantly, no formulas required.
Calculate Difference →

Common mistakes with time difference formulas

1. Not accounting for overnight shifts

Plain subtraction assumes the end time is later in the same day, so a shift running past midnight returns a negative duration unless it's wrapped in MOD(...,1).

2. Leaving the result cell formatted as date-time

Subtracting two time cells often inherits date-time formatting from one of the source cells, showing a full timestamp instead of a short h:mm duration.

3. Forgetting to convert to decimal hours before applying a rate

Multiplying an hourly rate directly against a raw time duration (which Excel stores as a fraction of a day) gives a tiny, meaningless number — the duration needs to be multiplied by 24 first to get usable decimal hours.

4. Comparing times across zones without adjusting the offset

Subtracting two local times from different time zones directly, without first converting both to a common reference, gives a gap that's off by however many hours separate the zones.

💡 Pro tip If a timesheet total resets to a small number instead of climbing past 24 hours, format the total cell as [h]:mm with square brackets — that tells the spreadsheet to keep accumulating hours instead of rolling over like a clock.

Real-world examples

A few common scenarios and the formula each one needs.

Day shift
Same-day duration
=B2-A2
Formatted as h:mm, works whenever the end time is later than the start time on the same day.
Night shift
Overnight, crossing midnight
=MOD(B2-A2,1)
Adds a day back in automatically so a 10 PM–6 AM shift still returns 8:00 instead of a negative value.
Hourly billing
Decimal hours for a rate
=MOD(B2-A2,1)*24
Converts a duration into a plain number like 7.5, ready to multiply by an hourly rate.
Weekly timesheet
Total hours across many rows
[h]:mm format
Sums daily durations without resetting at 24 hours, giving a correct weekly total.

Direct subtraction vs MOD formula vs decimal hours

A side-by-side look at how the three approaches compare.

Factor Direct subtraction MOD formula Decimal hours
Output Clock duration (h:mm) Clock duration (h:mm) Plain number (e.g. 7.5)
Handles overnight shifts No Yes Yes, if MOD-wrapped
Ready for rate math No No Yes
Best for Same-day durations, meeting lengths Night shifts, overnight call logs Payroll, hourly invoicing

Skip the formulas: free time difference calculator

If you just need the gap between two times and don't want to open a spreadsheet, the Rebrixe Time Difference Calculator works entirely in your browser: enter a start and end time, get the exact difference in hours and minutes instantly, overnight shifts included. No formulas, no account, no data sent anywhere.

Free Time Difference Calculator Enter two times, get the exact gap instantly.
Open Time Calculator →

Frequently asked questions

Subtract the start time from the end time, like =B2-A2 in a spreadsheet, and format the result cell as time (h:mm) to see the gap as hours and minutes rather than a date.
Wrap the subtraction in a MOD formula, like =MOD(B2-A2,1), which adds a full day back in whenever the end time is technically earlier than the start time, correctly handling overnight shifts.
A negative result happens when the end time crosses midnight and isn't corrected with MOD, and ##### usually means the result cell is formatted as time but the column is too narrow, or the value itself is negative.
Multiply the time difference by 24, like =(B2-A2)*24, and format the result as a number rather than time, which converts the fractional day into total decimal hours worked.
Yes, by converting both times to a common reference like UTC first, then subtracting, since directly subtracting local times from two zones without adjusting for the offset gives the wrong gap.
This happens when the result cell inherited a date-time format from one of the source cells, so it displays a full timestamp instead of the elapsed duration; changing the format to h:mm or Number fixes it.
Sum the individual daily differences with =SUM(), then format the total cell as [h]:mm with square brackets around the hours, which lets the total exceed 24 hours instead of resetting back to zero.

Get the exact time gap in seconds

Skip the formulas entirely — the Rebrixe Time Difference Calculator handles overnight shifts and decimal-hour conversion automatically, no spreadsheet required.

Launch the Time Calculator →
← Back to blogs