Excel guide · 4 min read
How to calculate hours worked (and overtime) in Excel
=C2-B2-D2. If you type real times like 8:30 AM, Excel stores them as fractions of a day, so multiply by 24 to get decimal hours: =(C2-B2)*24. For overtime, total the week and use =MAX(0,total-40) for the hours above 40.Sample data
Every result on this page was calculated from this sheet by the same spreadsheet engine the Cellwise app uses.
| A | B | C | D | E | F | G | H | I | |
|---|---|---|---|---|---|---|---|---|---|
| 1 | Day | In | Out | Break | Hourly rate | Night in | Night out | ||
| 2 | Mon | 8.5 | 17 | 0.5 | 22.5 | 22 | 6 | ||
| 3 | Tue | 8 | 18.5 | 0.5 | |||||
| 4 | Wed | 9 | 17.5 | 0.5 | |||||
| 5 | Thu | 7.5 | 18 | 0.75 | |||||
| 6 | Fri | 8 | 16.25 | 0.5 |
Download this sheet as an Excel practice file (.xlsx)
How Excel stores times (and why you multiply by 24)
In Excel a time is a fraction of a day: 6:00 AM is 0.25, noon is 0.5, 6:00 PM is 0.75. Subtracting 8:30 AM from 5:00 PM gives 0.354, which Excel shows as 8:30 if the cell has a time format. That is fine for display, but you cannot multiply it by an hourly rate directly: 0.354 x $22.50 is about $8.
Multiply the difference by 24 to turn it into decimal hours: =(C2-B2)*24 gives 8.5. Format that cell as Number, not Time. If you want to keep times on screen and total them, use the custom format [h]:mm. The square brackets let totals run past 24 hours; plain h:mm wraps a 43.5-hour week back to 19:30.
The examples below already use decimal hours (8.5 means 8:30, 17.25 means 5:15 PM), so no *24 is needed. Everything else works the same way.
- Type times with a colon, such as 8:30 AM or 17:00, so Excel recognizes them as times.
- For hours worked, use
=(C2-B2)*24and format the result as Number with 2 decimals. - For a time-style total, right-click the cell > Format Cells > Custom and type [h]:mm.
Hours for one shift, minus the break
End minus start minus break gives paid hours for the day. Monday runs 8:30 to 5:00 with a 30-minute unpaid break. Fill the formula down for the rest of the week.
With real time values, a break typed as 0:30 is already a fraction of a day, so the formula becomes =(C2-B2-D2)*24. If the break is typed in minutes (30), divide it: =(C2-B2)*24-D2/60.
Result: 8
17 - 8.5 - 0.5 = 8 paid hours on Monday.
Night shifts that end after midnight
A shift from 10 PM to 6 AM gives a negative number if you just subtract, because 6 is smaller than 22. MOD wraps the result around the clock. With decimal hours use MOD(out-in,24). With real Excel times use =MOD(out-in,1)*24, because a day is 1 in time values.
MOD only works for shifts shorter than 24 hours. For longer stretches, enter full date and time in both cells and subtract normally.
Result: 8
8 hours for the 22:00 to 6:00 shift, instead of -16.
Weekly total and overtime hours
You can add a daily hours column and SUM it, or let SUMPRODUCT do the subtraction for every row at once. The week totals 43.5 hours.
Overtime is whatever is above your threshold. MAX(0, ...) stops a short week from producing negative overtime. The threshold of 40 a week is common, but rules differ by country, state and contract (some count overtime per day), so put the number your employer uses in a cell if it might change.
Result: 3.5
43.5 hours worked, so 3.5 hours of overtime.
Daily overtime (hours over 8 each day)
If overtime is counted per day instead, compare each day to 8 and add only the excess. The (hours>8) part is TRUE or FALSE, which SUMPRODUCT treats as 1 or 0, so days under 8 contribute nothing.
Result: 3.75
3.75 hours: 2 on Tuesday (10 hours) and 1.75 on Thursday (9.75 hours).
Gross pay with time-and-a-half
Pay regular hours at the base rate and overtime at 1.5 times the rate. MIN(40, hours) caps the regular part; MAX(0, hours-40) is the overtime part. Here the hourly rate is in F2. ROUND to 2 decimals so the pay matches what a payroll system would print.
Result: 1018.13
40 x $22.50 + 3.5 x $33.75 = $1,018.13 for the week.
Common mistakes
Multiplying a time difference by the hourly rate
A time of 8:30 is stored as 0.354, so pay comes out tiny. Multiply by 24 first: =(C2-B2)*24*rate.
Weekly total shows 19:30 instead of 43:30
The h:mm format wraps at 24 hours. Use the custom format [h]:mm for totals, or convert to decimal hours with *24.
Typing 8.30 for half past eight
8.30 is 8.3 hours, which is 8 hours 18 minutes. Half past eight is 8.5 in decimal hours, or type 8:30 to get a real time.
Negative hours or ##### on overnight shifts
Excel cannot display a negative time, so it shows #####. Use =MOD(end-start,1)*24 for shifts that cross midnight.
FAQ
How do I convert hours and minutes to decimal hours in Excel?
Multiply a time value by 24: if A2 holds 7:45, =A2*24 gives 7.75. Format the result as Number, not Time.
How do I calculate hours between two times in Excel?
Use =(end-start)*24 for decimal hours. If the shift crosses midnight, use =MOD(end-start,1)*24.
Why does my time sheet total reset after 24 hours?
The h:mm format only shows the hours part of a day. Apply the custom format [h]:mm to the total cell and it will show 43:30.
How do I calculate overtime over 40 hours in Excel?
Total the hours for the week, then use =MAX(0,total-40) for overtime hours and =MIN(40,total) for regular hours. Multiply each by its rate.
Functions used
SUMPRODUCTMultiply then addMAXLargest numberMINSmallest numberMODRemainder after divisionROUNDRounds to digitsSUMAdds numbers
Related guides
- ##### in Excel: why it happens and how to fix it
- How to calculate sales commission in Excel
- Absolute vs relative cell references in Excel
- Excel formulas cheat sheet: the 25 everyone should know
- How to calculate due dates and days overdue in Excel
- How to make a gradebook in Excel
- How to calculate a loan payment in Excel
Updated