To calculate time taken in Excel, subtract the start time from the end time in a cell formatted as a time or duration, for example =B2-A2. If the result crosses midnight, add 1: =B2-A2+1. If the total exceeds 24 hours, apply the custom format [h]:mm so Excel does not wrap the result back to zero. That is the whole method; the rest of this guide covers formatting, common errors and edge cases.

What You'll Need

  • Excel on desktop (Windows or Mac) or Excel for the web. The steps below work in all three; menu labels can differ slightly by version and region.
  • Start and end times entered as real Excel times (for example 9:00 AM or 17:30), not as text.
  • Cells formatted as Time or as a custom duration format.

Step-by-Step

  1. Enter the start time in one column and the end time in the next. Type times in a format Excel recognises, such as 9:00, 9:00 AM or 17:30. Keep the columns consistent: do not mix 12-hour and 24-hour entries in the same column if you can avoid it.
  2. Make sure the cells are true times, not text. Select the time columns, right-click, choose Format Cells, pick the Number tab, choose Time, and click OK. If a value is left-aligned in the cell, it is probably text and will not calculate.
  3. Write the subtraction formula in a third column. With the start in A2 and the end in B2, enter =B2-A2 and press Enter. Drag the fill handle down to apply it to the rest of the rows.
  4. Format the result cell. Select the formula cells, open Format Cells (Ctrl+1 on Windows, Cmd+1 on Mac), go to the Number tab, choose Custom, and type h:mm for hours and minutes, or [h]:mm if the total can pass 24 hours. Click OK.
  5. Handle shifts that cross midnight. If the end time is earlier than the start time, Excel returns a negative value. Use =B2-A2+1 or the more robust =MOD(B2-A2,1), then apply the same time format.
  6. Convert to decimal hours if you need a number. Multiply the result by 24 and format the cell as a number: =(B2-A2)*24 gives hours as a decimal, such as 7.5. For minutes, multiply by 1440; for seconds, by 86400.
  7. Sum a column of durations. Use =SUM(C2:C10) and apply the [h]:mm custom format to the total cell, otherwise a total over 24 hours will display as a smaller time.

Common Mistakes

  • Times stored as text. If the subtraction returns #VALUE!, the times were typed or imported as text. Re-enter them in a recognised time format.
  • Using the default time format for totals. The standard h:mm format wraps at 24 hours, so 26 hours shows as 2:00. Use [h]:mm for any total that can exceed a day.
  • Forgetting the midnight case. A shift from 22:00 to 06:00 returns a negative value without the +1 or MOD adjustment.
  • Mixing date and time. If one cell contains a full date-time and the other only a time, the subtraction can be off by a whole day. Keep both cells consistent.
  • Formatting the result as General. A raw subtraction result is a fraction of a day, so 0.3125 displays instead of 7:30. Apply a time format.

Tips

  • Use =MOD(B2-A2,1) as your default formula; it handles both same-day and overnight shifts without extra logic.
  • Press Ctrl+; (Windows) or Cmd+; (Mac) to insert the current date, and Ctrl+Shift+; for the current time.
  • To round to the nearest quarter hour, wrap the result: =MROUND(B2-A2,"0:15").
  • If you need to subtract a break, subtract it as a time value: =(B2-A2)-TIME(0,30,0) removes 30 minutes.
  • Name your columns clearly (Start, End, Duration) so formulas stay readable as the sheet grows.

Troubleshooting

  • Result shows #####: the column is too narrow. Widen it.
  • Result shows a negative time or #VALUE!: check that both cells are real times. Select each cell and look at the formula bar; a leading apostrophe or a left-aligned value means text.
  • Result shows a decimal like 0.3125: the cell is formatted as General or Number. Apply the h:mm or [h]:mm format.
  • Total wraps at 24 hours: change the total cell's custom format to [h]:mm.
  • Overnight shift gives a negative number: switch to =MOD(B2-A2,1) or add 1 to the subtraction.
  • Times imported from another system will not calculate: use Data > Text to Columns and set the column type to Time, or re-enter the values manually.

Frequently Asked Questions

Why does my time difference show as a decimal?

The result cell is formatted as General or Number. Excel stores times as fractions of a day, so apply a Time or Custom h:mm format to display it as hours and minutes.

How do I calculate time taken when the shift crosses midnight?

Use =MOD(B2-A2,1) or =B2-A2+1. Both return a positive duration for an end time that falls on the next day.

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

Multiply the difference by 24, for example =(B2-A2)*24, and format the cell as a number. Multiply by 1440 for minutes.

Why does my total show 2:00 instead of 26:00?

The cell is using the standard time format, which wraps every 24 hours. Apply the custom format [h]:mm to show the full duration.

Can I subtract a lunch break from the total?

Yes. Subtract a time value from the result, for example =(B2-A2)-TIME(0,30,0) for a 30-minute break, and keep the duration format on the cell.

Does this work in Excel for the web?

Yes. The same formulas and the Format Cells dialog work in Excel for the web, though some advanced custom formats are limited compared with the desktop app.