<link rel="stylesheet" type="text/css" href="/mirawhite.css">

How to calculate hours between two times in Excel

Updated November 24, 2026

Put the start time in A2 and the end time in B2, then type =B2-A2 in C2: Excel returns the duration as a time, such as 8:45. Multiply by 24, =(B2-A2)*24, to get decimal hours (8.75), and use =MOD(B2-A2,1) when the shift ends after midnight. The same formulas work in Google Sheets.

Subtract the start time from the end time

Excel stores a time as a fraction of a day: 12:00 PM is 0.5 and 6:00 AM is 0.25. Subtracting two times therefore gives another fraction of a day, which Excel can display as hours and minutes.

  1. Type the start time in A2 and the end time in B2, with a colon: 8:30 AM or 8:30, 5:15 PM or 17:15.
  2. In C2, type =B2-A2 and press Enter.
  3. If the result looks like 0.364583 or 8:45 AM, select C2 and press Ctrl+1 (Cmd+1 on a Mac) to open Format Cells.
  4. On the Number tab, choose Custom, type h:mm in the Type box and click OK.
  5. Fill the formula down for the other rows.
=B2-A2

Good to know : Type times with a colon. Excel reads 8.30 as the number 8.3, and text such as 8h30 is not recognized as a time, so the subtraction returns #VALUE!.

Show totals over 24 hours with [h]:mm

When you add up a week of durations with =SUM(C2:C8), a total of 40 hours and 30 minutes shows as 16:30 with the h:mm format, because the clock restarts every 24 hours. The square brackets tell Excel to keep counting hours.

  1. Select the total cell, or the whole duration column.
  2. Press Ctrl+1 and open the Number tab.
  3. Choose Custom and type [h]:mm in the Type box.
  4. Click OK: the total now reads 40:30.

Good to know : Use [h]:mm:ss to show seconds, and [m] to show the total in minutes only.

Convert the result to decimal hours

Payroll and invoices usually need decimal hours: 8 hours 45 minutes is 8.75 hours. Since a day equals 1 in Excel, multiply the duration by 24. Format the result cell as Number or General, otherwise Excel may still show it as a time.

  • Round to two decimals with =ROUND((B2-A2)*24,2), since some results come out as 8.7499999.
  • Multiply by 1440 instead of 24 to get minutes.
  • Pay for the shift: =(B2-A2)*24*E2, with the hourly rate in E2.
  • Avoid HOUR(B2-A2) for this: it returns only the whole hours, from 0 to 23, and drops the minutes.
=(B2-A2)*24

Night shifts that end after midnight

From 10:00 PM to 6:00 AM, =B2-A2 gives a negative value, which Excel shows as #####. MOD adds a day when the end time is earlier than the start, and returns 8:00. It works for any shift shorter than 24 hours.

=MOD(B2-A2,1)

Good to know : For decimal hours on a night shift, use =MOD(B2-A2,1)*24. If your cells hold a full date and time, such as 3/14/2026 10:00 PM, plain subtraction already handles midnight and several days: =(B2-A2)*24 gives the total hours.

Hours worked with breaks and overtime

A simple timesheet has one row per day with Start in B, Break start in C, Break end in D and End in E. The daily hours are the full span minus the break. For a fixed 30-minute lunch, subtract TIME(0,30,0) instead.

  • Fixed break: =E2-B2-TIME(0,30,0).
  • Weekly total in F9: =SUM(F2:F8), formatted as [h]:mm.
  • Overtime beyond 40 hours, in decimal hours: =MAX(0,F9*24-40).
  • Date in one column and time in another: =A2+B2 combines them into one date and time.
=(E2-B2)-(D2-C2)

Calculate hours between two times in Google Sheets

Google Sheets uses the same formulas: =B2-A2, =(B2-A2)*24 and =MOD(B2-A2,1). To display the result, select the cells and go to Format > Number > Duration, which also shows totals over 24 hours. For hours and minutes without seconds, open Format > Number > Custom number format and enter [h]:mm.

As in Excel, a decimal result needs the Number format, and times typed as text, with a letter or an extra space, are not calculated.

Common problems

  • ##### in the cell: the result is negative, usually a shift past midnight. Use MOD, or add the dates to the times.
  • The total is too small: the cell uses h:mm instead of [h]:mm, so every full 24 hours is dropped.
  • The result shows 0.36 or 8:45 AM: the cell format is wrong. Use h:mm for a duration, or Number for decimal hours.
  • #VALUE!: one of the times is text. Retype it with a colon, or convert it with =TIMEVALUE(A2) when it looks like 8:30 but is aligned to the left.

Count the hours online with Utiloz

Without a spreadsheet, the Hours between two times calculator on Utiloz gives the duration as you type a start and an end time: 8:30 AM, 8.30pm, 20:30 or 830 all work. You can subtract a break, add several time slots for a split shift, and read the total in hours and minutes, in decimal hours and in minutes.

It runs in your browser with no sign-up. An end time earlier than the start is counted on the next day and the slot is flagged. Without AM or PM, times are read on a 24-hour clock, each slot must last less than 24 hours, and daylight saving time changes are not taken into account. Decimal hours are rounded to the hundredth.

Frequently asked questions

What is the formula for hours between two times in Excel?

=B2-A2 gives the duration as a time, to format as h:mm, and =(B2-A2)*24 gives decimal hours. For a shift that ends after midnight, use =MOD(B2-A2,1).

How do I calculate hours between two times in Google Sheets?

Type =B2-A2 and apply Format > Number > Duration, or use =(B2-A2)*24 for decimal hours. =MOD(B2-A2,1) handles night shifts, exactly as in Excel.

Why does Excel show ##### when I subtract two times?

The result is negative, which Excel cannot display as a time in the default date system. It usually means the shift crosses midnight: =MOD(B2-A2,1) fixes it.

How do I sum hours over 24 in Excel?

Use =SUM() as usual, then format the total cell with the custom format [h]:mm. Without the brackets, Excel drops every full day and 40:30 shows as 16:30.

← All guides