Learn Excel
EN
Sets how numbers, dates and formulas look, so everything works just like your own Excel.

Home › Excel basics › Time difference & hours worked

Calculate Time Difference and Hours Worked in Excel

To calculate the time difference in Excel, subtract the start time from the end time: =B2-A2. Multiply by 24 to get hours as a number you can use for pay. This guide builds a small timesheet, including breaks, night shifts and weekly totals above 24 hours.

In this guide
  1. How Excel stores time
  2. Hours worked minus breaks
  3. Try it yourself
  4. Past midnight
  5. Totals over 24 hours
  6. Plus and minus hours
  7. Days, hours and minutes
  8. Useful time functions
  9. Common problems
  10. More formulas
  11. Keep learning
  12. FAQ

How Excel stores time

Excel stores a day as 1, so an hour is 1/24 and 12:00 is 0.5. That's why subtracting times works, and why multiplying by 24 turns a time into hours:

FormulaShowsFormat
=B2-A28:30Time (h:mm)
=(B2-A2)*248.5Number (decimal hours)
=(B2-A2)*1440510Number (minutes)

With 9:00 in A2 and 17:30 in B2. If =(B2-A2)*24 shows a time like 12:00, set the cell format to Number.

Timesheet: hours worked minus breaks

ABCDE
1DayStartEndBreakHours
2Mon9:0017:300:308.00
3Tue8:3017:000:457.75
4Wed22:006:000:307.50
5Total23.25

In E2, then fill down:

=(MOD(C2-B2, 1) - D2) * 24
  • C2-B2 is the time between start and end.
  • MOD(…, 1) handles shifts past midnight (see below). For day shifts it changes nothing.
  • - D2 deducts the break, entered as a time (0:30).
  • * 24 gives decimal hours: 7:45 becomes 7.75.

The total in E5 is =SUM(E2:E4) = 23.25 hours. With an hourly rate of 15 in G1, the pay is =E5*G1 = 348.75.

Try it yourself: hours worked as a decimal

Reading is one thing, typing it is another. Build the formula below step by step: the tips tell you what to type next, and you can click or drag across cells to add them, just like in Excel.

Task: Work out in D2 how many hours Mia worked, as a decimal number: =(C2-B2)*24

Night shifts past midnight

For 22:00 to 6:00, =C4-B4 is negative, and Excel shows #### because it can't display negative times. Two fixes:

=MOD(C4-B4, 1) =C4-B4+(C4<B4)

Both add a day when the end time is earlier than the start time, giving 8:00. The MOD function version is the most common. If your shifts can last longer than 24 hours, enter full date and time in both cells (e.g. 3-11-2026 22:00) and simply subtract.

Totals over 24 hours

Add up times in h:mm format and a weekly total of 38:30 can show as 14:30: Excel rolls over at each full day. Fix the format:

  1. Select the total cell and press Ctrl+1.
  2. Choose Custom and enter [h]:mm.

The square brackets tell Excel to keep counting hours past 24. Use [mm] for total minutes.

Plus and minus hours: show a negative balance

A flexitime balance compares the hours worked with the contracted hours. On a short day the difference is negative, and in h:mm format Excel shows ####. Two ways to keep it readable:

  • Work in decimal hours. With decimal hours in E2 and an 8-hour day: =E2-8 gives -0.5 for a day of 7.5 hours. Negative numbers display normally, and the balance for the week is a plain SUM.
  • Show it as text. With a time difference in F2: =IF(F2<0, "-", "") & TEXT(ABS(F2), "[h]:mm") shows -0:30. The result is text, so keep calculating with F2 itself.

The 1904 date system (File › Options › Advanced) can also show negative times, but switching it moves every date already in the workbook by four years. Only use it in a workbook without dates.

Difference between two dates with times

When both cells hold a date and a time, for example 11/3/2026 8:00 in A2 and 11/5/2026 14:30 in B2, subtract them in the same way: =B2-A2 gives 2.27 days. Choose how to show it:

FormulaShows
=(B2-A2)*2454.5 (hours as a number)
=B2-A2 with format [h]:mm54:30
=INT(B2-A2) & " days " & TEXT(B2-A2, "h:mm")2 days 6:30

INT takes the whole days, and h:mm shows only what is left after them. To skip weekends, count the working days with NETWORKDAYS first.

Useful time functions

You wantFormula
Hours part of a duration=HOUR(B2-A2)
Minutes part=MINUTE(B2-A2)
Build a time from numbers=TIME(8, 30, 0)
Current time=NOW()-TODAY()
Show a duration as text=TEXT(B2-A2, "h:mm")
Round to the nearest 15 minutes=MROUND(B2-A2, "0:15")

HOUR only returns 0–23, so don't use it for totals above a day; multiply by 24 instead. For days between dates, see DATEDIF and NETWORKDAYS.

Common problems

  • #### in the cell. The result is negative (shift past midnight) or the column is too narrow.
  • #VALUE! One of the times is text. Retype it, or see convert text to numbers.
  • Pay is way too low. You multiplied a time (0.33 of a day) by the hourly rate. Multiply by 24 first.
  • Break typed as 30. That means 30 days. Type 0:30, or divide minutes by 1440.

More formulas

Copy a formula and change the ranges to match your own data.

What you wantFormula
End time minus start time (format the cell as h:mm)=C2-B2
Hours as a decimal number, for example 7.5=(C2-B2)*24
A shift past midnight (22:00 to 06:00)=MOD(C2-B2, 1)
Hours worked minus a break in D2=(C2-B2-D2)*24
Weekly total: format as [h]:mm so it can go past 24 hours=SUM(E2:E8)

Frequently asked questions

How do I convert 7:45 to 7.75 hours?

Multiply by 24: =A2*24, and format the result as a number.

How do I convert 7.75 hours back to 7:45?

Divide by 24: =A2/24, and format the cell as h:mm.

How do I calculate overtime above 8 hours a day?

With decimal hours in E2: =MAX(E2-8, 0) gives the overtime, and =MIN(E2, 8) the regular hours.

How do I enter the time quickly?

Press Ctrl+Shift+; to insert the current time as a fixed value. Typing 9:00 or 9:00 PM also works.

How do I convert hours to working days?

Divide decimal hours by the length of a working day: =E5/8 turns 23.25 hours into 2.91 days of 8 hours. If the total is a time (h:mm), multiply by 24 first: =E5*24/8.

How do I calculate the average hours per day?

Use AVERAGE on the decimal hours: =AVERAGE(E2:E4) gives 7.75. Days off with 0 hours pull the average down; =AVERAGEIF(E2:E8, ">0") only counts the days you worked.

How do I add up the hours per month?

Put a date in each row of column A and the first day of the month in H1. Then =SUMIFS(E:E, A:A, ">="&H1, A:A, "<"&EDATE(H1, 1)) adds up the hours of that month only. See SUMIFS.