Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

How to Find Time Difference in Excel

· 6 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To find the time difference in Excel, subtract the start time from the end time and format the result as a time or as hours and minutes. For example, if A2 contains 9:00 AM and B2 contains 5:30 PM, the formula =B2-A2 returns 8:30 when the cell is formatted as h:mm. That single subtraction is the core method; the rest of this guide covers formatting, overnight shifts, totals over 24 hours, and the errors that make the result look wrong.

What You'll Need

  • Excel on Windows, Mac, or the web (the formulas below work in all three; menu labels can differ slightly by version, device, or region).
  • Start and end times entered as real Excel times, not as text. Typing 9:00 AM or 17:30 into a cell that is formatted as General usually produces a valid time, but if Excel treats it as text the subtraction will fail.
  • Two cells per calculation: one for the start time and one for the end time.

Step-by-Step

  1. Enter the start time in cell A2. Type it with a space before AM/PM, for example 9:00 AM, or use 24-hour format such as 09:00. Press Enter. Excel stores it as a fraction of a day, even though it displays as a time.
  2. Enter the end time in cell B2 the same way, for example 5:30 PM or 17:30.
  3. Write the subtraction formula in cell C2: =B2-A2. Press Enter. If both cells contain valid times, C2 now holds a decimal number such as 0.354166, which is the fraction of a day between the two times.
  4. Format the result as a time. Select C2, right-click, choose Format Cells, go to the Number tab, and pick Time. Choose a format like h:mm for hours and minutes, or h:mm:ss if you need seconds. Click OK. The cell now shows 8:30.
  5. Copy the formula down if you have more rows. Drag the fill handle from C2 down the column. Each row calculates its own difference.
  6. Handle overnight shifts. If the end time is earlier than the start time (for example 10:00 PM to 6:00 AM), plain subtraction gives a negative number that displays as ##### or a negative time. Use =MOD(B2-A2,1) instead. MOD wraps the negative result around a 24-hour clock and returns 8:00. Format the cell as h:mm.
  7. Show total hours as a number. To get a decimal hour value, multiply the difference by 24: =(B2-A2)*24. Format the cell as Number with two decimal places. For 8:30, this returns 8.5. For minutes, use =(B2-A2)*1440; for seconds, multiply by 86400.
  8. Sum several differences. If you add up a column of formatted times and the total exceeds 24 hours, Excel may display only the remainder. Select the total cell, open Format Cells, choose Custom, and enter [h]:mm. The square brackets tell Excel to keep counting past 24 hours instead of rolling over at midnight.
  9. Convert to text if needed. To display a difference as a label such as "8 hours 30 minutes", use =INT((B2-A2)*24)&" hours "&ROUND(MOD((B2-A2)*1440,60),0)&" minutes". This is useful for reports where the reader should not have to interpret a time format.

Common Mistakes

  • Leaving the result formatted as General. The subtraction works, but you see 0.354166 instead of 8:30. Always apply a time format to the result cell.
  • Entering times as text. If a time was pasted from another system, it may be stored as text. Check by selecting the cell: if the formula bar shows the time but the cell is left-aligned by default, it may be text. Use Data > Text to Columns or re-enter the time manually.
  • Forgetting the MOD wrapper for overnight shifts. Plain subtraction across midnight returns a negative value. Excel cannot display negative times in its default date system, so you get #####.
  • Summing with h:mm instead of [h]:mm. A total of 30 hours shows as 6:00, which looks like a bug but is just the format rolling over.
  • Mixing date and time. If one cell contains a full date and time and the other contains only a time, the difference can be off by whole days. Either include dates in both cells or strip the date part with MOD(A2,1) before subtracting.

Tips

  • Use 24-hour input (17:30 rather than 5:30 PM) to avoid ambiguity and typing errors.
  • Press Ctrl+1 (Windows) or Cmd+1 (Mac) to open Format Cells quickly.
  • If you need the result in a specific unit, multiply by 24 for hours, 1440 for minutes, or 86400 for seconds, then format as a number.
  • Keep start and end times in separate columns. Combining them into one text cell makes formulas fragile.
  • For a running total of hours worked in a week, use [h]:mm on the total cell so it can exceed 24 hours.

Troubleshooting

  • The result shows #####. The column is too narrow, or the result is negative. Widen the column first. If it is still negative, the end time is earlier than the start time; switch to =MOD(B2-A2,1).
  • The result is a decimal like 0.354166. The cell is formatted as General or Number. Apply a Time format.
  • The formula returns #VALUE!. One of the cells contains text rather than a time. Re-enter the time or convert the text to a time value.
  • The total is wrong after adding several rows. Check the total cell's format. Use [h]:mm for totals that may exceed 24 hours.
  • Times look correct but the difference is off by hours. Check for a date mismatch: one cell may include a date and the other may not. Use MOD to strip dates, or enter full date-and-time values in both cells.
  • Excel on the web behaves differently. Most formulas work the same, but some custom formats and the Format Cells dialog are simplified. If a format is not available, use the Home tab's number format dropdown or switch to the desktop app.

Frequently Asked Questions

Why does my time difference show a decimal instead of hours and minutes?

Excel stores times as fractions of a day, so the raw subtraction returns a decimal. Format the result cell as Time (for example h:mm) to display it as hours and minutes.

How do I calculate the difference when the shift crosses midnight?

Use =MOD(B2-A2,1). The MOD function wraps the negative result around a 24-hour clock and returns the correct positive duration.

How do I get total hours as a number instead of a time?

Multiply the difference by 24: =(B2-A2)*24. Format the cell as a number. For minutes, multiply by 1440; for seconds, by 86400.

Why does my total show 6:00 when it should be 30:00?

The total cell is using a format that rolls over at 24 hours. Apply a custom format of [h]:mm to let it display hours beyond 24.

Can I subtract times that include dates?

Yes. If both cells contain full date and time values, plain subtraction returns the difference in days. Format the result as [h]:mm or multiply by 24 to get hours.

What if my times were pasted as text?

Excel cannot subtract text. Re-enter the times manually, or use Data > Text to Columns to convert the column, then apply a time format.