How to Calculate Time Duration in Excel

Excel can subtract times perfectly well, but it hides the answer behind fractions of a day and formats that roll over at 24 hours. This guide gives you the working formulas for time duration in Excel: plain spans, overnight shifts, totals over a day, and the decimal hours that payroll actually wants.

By Johnson Ramzan · Updated November 6, 2026

Open the Time Duration Calculator

Just need the number? The free time duration calculator skips the formatting traps entirely and returns the duration directly. This guide teaches the spreadsheet method for when the numbers have to live in Excel.
Home / Guides / Time Duration in Excel

Everything confusing about time in Excel comes from one fact: Excel does not store times as times. It stores them as fractions of a day. Noon is 0.5, 6 PM is 0.75, and one hour is 1/24, about 0.0417. A duration is the difference between two of those fractions, which is why subtracting two time cells works instantly, and why the result so often displays as something bizarre like a date in 1900 or a neat row of hash signs. The arithmetic is almost never wrong; the display is.

Once you accept the fraction idea, every formula in this guide becomes predictable. Subtract to get a fraction of a day. Format it as [h]:mm to read it as a duration. Multiply it by 24 to get decimal hours, by 1,440 to get minutes, by 86,400 to get seconds. Google Sheets uses the identical system, so every formula below works there too, unchanged.

The basic formula and the one format that matters

  1. Put the start time in A2 and the end time in B2, typed so Excel recognises them as times, like 9:15 AM or 17:45.
  2. In C2 enter =B2-A2. Excel returns a fraction of a day.
  3. Select C2, open Format Cells, choose Custom, and enter [h]:mm. The brackets are essential: they allow hours above 24.
  4. For decimal hours, use =(B2-A2)*24 in a cell formatted as a number.
  5. Copy the formulas down for every row, and total the duration column with a plain SUM, keeping [h]:mm on the total cell.

Worked example: start 9:15 AM, end 5:45 PM. The subtraction gives 0.3542 of a day. Formatted as [h]:mm it displays 8:30. Multiplied by 24 it gives 8.5 hours. All three are the same duration wearing different clothes, and choosing the right display for the job is most of the skill. Send the [h]:mm version to a human, the decimal version to payroll.

Overnight spans and the MOD fix

Time-only cells have no date attached, so a shift from 10:30 PM to 6:15 AM subtracts to a negative fraction, and Excel answers with ####### rather than a duration. The clean fix is =MOD(B2-A2,1). MOD returns what is left after wrapping around whole days, so the formula effectively adds a day whenever the end is earlier than the start, and the result is 0.3229 of a day, displayed as 7:45 with [h]:mm. If your cells hold full dates and times together, plain subtraction already works, because the end value is genuinely bigger; that is the more robust setup whenever the data allows it. The same wrap logic powers the hand method in our guide to durations that fall on different days.

A vintage twin-bell alarm clock on a wooden bookshelf - How to Calculate Time Duration in Excel
Excel stores a duration as a fraction of a day. The formula is easy; the format is where answers hide.

Totalling a column without losing a day

The classic spreadsheet disaster is a week of durations that sums past 24 hours. Five shifts of 6:30, 7:45, 8:15, 5:50 and 3:10 total 31 hours 30 minutes. Summed in a cell formatted h:mm, Excel shows 7:30, because the plain format rolls over every day and silently discards the extra 24 hours. Nothing about the total looks wrong, which is why this error survives audits. The defence is boring and total: put [h]:mm on every duration cell and especially on the total, and the same column reads 31:30. Check the minutes arithmetic once by hand (the five shifts are 390 + 465 + 495 + 350 + 190 = 1,890 minutes, and 1,890 / 60 = 31.5 hours) and you will never trust an unbracketed total again.

Durations with dates, and text output

When start and end live in single cells as full date-times, like 3/3/2026 9:00 AM, subtraction handles multi-day spans with no special treatment: March 3 at 9:00 AM to March 7 at 4:30 PM returns 4.3125 days, which [h]:mm shows as 103:30 and multiplying by 24 shows as 103.5 hours. If you need the answer as readable text inside a report, the TEXT function formats the fraction directly: =TEXT(B2-A2,"[h] hours m minutes") produces words like "8 hours 30 minutes" that can sit inside a sentence. One caution: a TEXT result is text, not a number, so keep the numeric version in its own column for any further calculation. This date-time approach is the spreadsheet twin of the method in our guide to the duration between two dates and times, and it feeds naturally into billing work, where durations become amounts, as covered in our guide to calculating duration for billing.

The five errors you will eventually meet

They are worth listing because every Excel timesheet meets all five. One: a date in 1900 on screen means the result cell has a date format; switch to [h]:mm. Two: ####### means a negative duration; use MOD or add dates. Three: a total that is exactly 24 hours short means the total cell lacks brackets. Four: an answer like 0.35 when you expected 8.5 means the cell is showing the raw fraction; multiply by 24. Five: #VALUE! means one of the "times" is actually text, usually because it was typed with a stray space or in a format Excel did not recognise; retype it as 9:15 AM and the formula wakes up. None of these are calculation errors. All of them are display and data-entry issues, which is why a quick hand check of one row against a known answer, like the 9:15 to 5:45 example above, is worth doing on any new sheet.

Try it the fast way

When a duration does not need to live in a spreadsheet, the time duration calculator returns it directly in days, hours, minutes and seconds, with no formats to fix. And when you have a list of separate durations to total, the time calculator on the homepage adds them without a SUM formula in sight.

Frequently asked questions

Why does Excel show a date like 1/8/1900 instead of my duration?

Excel stores times as fractions of a day counted from January 1, 1900, and a result cell formatted as a date displays that fraction as a calendar date. A duration of 8.5 hours is the fraction 0.354, which the date format shows as a day in January 1900. Reformat the cell as [h]:mm or as a number and the duration reappears.

Why do I see ####### in my duration cell?

A row of hash signs usually means the result is a negative time, which Excel refuses to display in its default date system. It happens when the end time is earlier than the start time, as with overnight shifts. Wrap the subtraction in MOD, like =MOD(B2-A2,1), and the span wraps past midnight correctly instead.

How do I total durations that add up to more than 24 hours in Excel?

Use the elapsed-hours format [h]:mm on the total cell. The square brackets tell Excel to keep counting past 24 instead of rolling over into days. Without them, a column totalling 31 hours 30 minutes displays as 7:30, which is the single most common timesheet error in spreadsheets.

How do I get a duration as decimal hours in Excel?

Multiply the subtraction by 24: =(B2-A2)*24. Excel times are fractions of a day, so multiplying by 24 converts the fraction into hours. An 8 hour 30 minute span becomes 8.5, ready for payroll rates and billing. Format the cell as a number with two decimal places.

How do I calculate a duration that crosses midnight in Excel?

Either include the dates with the times, so the end value is genuinely larger, or use =MOD(end-start,1) for time-only cells. MOD returns the positive remainder after wrapping, turning a 10:30 PM to 6:15 AM shift into 7:45 instead of an error. Including full dates is the more robust option when you have them.

About the author
Johnson Ramzan builds and maintains every calculator on Time Calculator Tools himself, and he tests each one against worked examples he has done by hand before it is allowed near a reader. His guides follow US Department of Labor guidance on hours worked, overtime and rounding, and he writes them the way he would want a payslip explained to him: plain English, real numbers, and no step skipped. When a reader writes in with a shift pattern the tools handle badly, fixing it goes to the top of his list.
Last updated: November 6, 2026

Related guides

How to Calculate the Duration Between Two Times

The by-hand foundation: convert both times to minutes, subtract once, and handle midnight with a single extra step.

Read the guide

How to Calculate Duration Between Two Dates and Times

Multi-day spans by the anchor method, which is exactly what a date-time subtraction in Excel is doing under the hood.

Read the guide

How to Calculate Duration for Billing and Invoices

Where spreadsheet durations end up: billable hours, rounding increments and decimal entries a client will accept.

Read the guide

How to Calculate How Many Hours Are Between Two Dates

The single-number version: whole days times 24 plus the leftover hours, with rentals and deadlines as examples.

Read the guide