Calculate Time Between Two Times

Excel Formulas › Date & Time

All versionsTime math

To find the hours between a start and end time — shift length, time logged — subtract the two and multiply by 24. Excel stores time as a fraction of a day, so the ×24 turns it into hours.


Quick formula: for a start time in A2 and end time in B2:
=(B2 - A2) * 24
The subtraction gives a fraction of a day; multiplying by 24 converts it to decimal hours (e.g. 8.5).

Functions used (tap for the full reference guide):

The example

Shift start and end times, converted to hours worked.

ABC
1StartEndHours
29:00 AM5:30 PM8.5
38:15 AM12:00 PM3.75

The formula

Hours worked in C2:

=(B2 - A2) * 24 // 5:30 PM − 9:00 AM = 0.354 day × 24 = 8.5 h

How it works

Time is a fraction of a day under the hood:

  1. Excel stores 24 hours as 1.0, so 6:00 AM is 0.25, noon is 0.5, and so on.
  2. Subtracting two times gives the elapsed fraction of a day.
  3. Multiplying by 24 converts that fraction to hours — 0.354 → 8.5.
  4. Format the result cell as a number, not time, or you’ll see “8:30” instead of “8.5.”

Crossing midnight? A shift from 10 PM to 6 AM gives a negative result. Wrap with MOD: =MOD(B2 - A2, 1) * 24 handles the overnight wrap correctly.

Try it: interactive demo

Live demo

Pick a start and end time; see the hours between.

Hours:

Variations

Handle overnight shifts

MOD wraps past midnight:

=MOD(B2 - A2, 1) * 24

Show as h:mm duration

Keep it as time and use a bracketed format:

=TEXT(B2 - A2, "[h]:mm")

Total minutes

Multiply by 1440 instead of 24:

=(B2 - A2) * 1440

Pitfalls & errors

Result shows as a time. The cell often inherits time formatting — format it as Number to see decimal hours.

Negative time across midnight. Plain subtraction breaks for overnight shifts. Use MOD(B2-A2, 1)*24.

Over 24 hours needs [h]. To display durations beyond a day, use the bracketed format [h]:mm so hours don’t roll over.

Practice workbook

📊
Download the free Calculate Time Between Two Times practice workbook
Shift times with live hours-between, the overnight MOD, [h]:mm, and minutes variants, plus 4 challenges with answers. No sign-up required.

Frequently asked questions

How do I calculate hours between two times in Excel?
Subtract and multiply by 24: =(B2 - A2) * 24. Excel stores time as a fraction of a day, so the ×24 converts it to decimal hours. Format the cell as a number.
How do I handle a shift that crosses midnight?
Use MOD to wrap the negative result: =MOD(B2 - A2, 1) * 24 correctly counts hours for an overnight shift like 10 PM to 6 AM.
Why does my time difference show as a clock time?
The cell is formatted as time. Change it to Number for decimal hours, or use =TEXT(B2-A2, "[h]:mm") to show a duration.

Stop fighting formulas. Learn them in a day.

This recipe is one of hundreds of real-world formulas we teach. Our Excel Formulas & Functions class covers lookups, logic, text, and dynamic arrays hands-on — live in Dallas–Fort Worth, Houston, Austin, Oklahoma City, Denver, or online.

See the Formulas & Functions Class

Related formulas: Days until a date · Working days between dates · Round to the nearest X

Function references: TEXT · MOD