How-to recipes · Dates and times
How to calculate overtime in Excel
Build a timesheet that works out daily hours, overtime above 8 hours a day or 40 a week, night shifts past midnight, and overtime pay.
A simple timesheet records when each shift starts and ends. From that you need the hours worked, the part of those hours that counts as overtime, and finally the pay with overtime at a higher rate. The rules differ: some contracts count overtime above 8 hours a day, others above 40 hours a week, and night shifts that pass midnight break the naive end minus start formula. This recipe builds a small, robust timesheet step by step. The formulas are the same in Microsoft 365 and older versions.
The example data
One week of shifts in A1:F6, with start and end times, an unpaid break in hours, and columns for hours worked and overtime. Thursday is a night shift from 22:00 to 06:30. The hourly rate is 18, with overtime paid at 1.5 times.
Step 1: hours worked, including night shifts
Subtracting times gives a fraction of a day. MOD(C2-B2,1) turns a negative result (end after midnight) into the correct positive duration, multiplying by 24 converts it into hours, and the break is subtracted:
| A | B | C | D | E | |
|---|---|---|---|---|---|
| 1 | Day | Start | End | Break | Hours |
| 2 | Mon | 08:00 | 17:30 | 0.5 | |
| 3 | Tue | 08:00 | 16:30 | 0.5 | |
| 4 | Wed | 07:30 | 18:00 | 0.5 | |
| 5 | Thu | 22:00 | 06:30 | 0.5 | 8 |
| 6 | Fri | 08:00 | 15:00 | 0.5 |
Thursday 22:00 to 06:30 is 8.5 hours; minus a 0.5-hour break gives 8. Without MOD the result would be -16.
Result: 8
Copy the formula from E2 to E6. MOD with divisor 1 keeps only the fraction of a day: -0.6458 becomes 0.3542, which is 8.5 hours. For shifts that never pass midnight =(C2-B2)*24-D2 is enough, but the MOD version handles both cases, so use it everywhere.
Step 2: daily overtime above 8 hours
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Day | Start | End | Break | Hours | Overtime |
| 2 | Mon | 08:00 | 17:30 | 0.5 | 9 | |
| 3 | Tue | 08:00 | 16:30 | 0.5 | 8 | |
| 4 | Wed | 07:30 | 18:00 | 0.5 | 10 | 2 |
| 5 | Thu | 22:00 | 06:30 | 0.5 | 8 | |
| 6 | Fri | 08:00 | 15:00 | 0.5 | 6.5 |
Wednesday: 10 hours worked, so 2 hours are overtime.
Result: 2
MAX returns the larger of 0 and the hours above 8, so days with less than 8 hours give 0 instead of a negative number. Copied down, the overtime column shows 1, 0, 2, 0, 0: 3 hours in total. Regular hours are =MIN(8,E2) with MIN, or simply =E2-F2.
Weekly overtime above 40 hours
If your rules count overtime per week instead, sum the hours and apply the same idea: =MAX(0,SUM(E2:E6)-40). The week has 41.5 hours, so weekly overtime is 1.5 hours. Some contracts combine both rules (daily overtime first, then weekly overtime on the remaining regular hours); calculate the daily overtime as above, then apply =MAX(0,SUM(E2:E6)-SUM(F2:F6)-40) to the regular hours so no hour is counted twice.
Step 3: pay
With the rate in a cell, say H1 = 18, and the overtime factor in H2 = 1.5:
=(SUM(E2:E6)-SUM(F2:F6))*H1+SUM(F2:F6)*H1*H2Regular hours 38.5 × 18 = 693, plus overtime 3 × 18 × 1.5 = 81, gives 774. Keeping the rate and factor in cells means you can change them without editing formulas, and lock them with Cell references: relative, absolute and mixed if you write the pay per row.
Showing hours as h:mm
The formulas above work in decimal hours, which is what payroll needs. If you prefer the timesheet to show 9:00 instead of 9, drop the *24, format the hours column as [h]:mm, and compare with TIME(8,0,0) instead of 8: =MAX(0,E2-TIME(8,0,0)). Convert to decimal only for the pay: =SUM(F2:F6)*24*H1*H2. See How to convert decimal hours to time in Excel and How to sum time over 24 hours in Excel.
Pitfalls
- Rounding errors. Time arithmetic can produce 1.9999999 hours. Round the hours before comparing:
=ROUND(MOD(C2-B2,1)*24-D2,2). - Shifts over 24 hours cannot be captured with time-only cells. Enter full date and time values for start and end, and use
=(C2-B2)*24. - Breaks in minutes. If the break is entered as 30 (minutes), divide it by 60 before subtracting.
- Weekend and holiday premiums. Use IF with the day:
=IF(A2="Sun",E2*H1*2,...), or a lookup table of rates per day type. - Local law. Overtime thresholds, rest periods and rates are set by contracts and labour law; the formulas model the rule, they do not decide it.