Calculate hours worked minus lunch (and night shifts)
Updated · Checked on a live sheet · Excel and Google Sheets
The formula
=MOD(D2-C2,1)*24-E2/60 gives the hours worked as a decimal number: end time minus start time, turned into hours, minus a break given in minutes. MOD(…, 1) makes it work for night shifts that end after midnight.
In general: =MOD(end-start,1)*24-break_minutes/60
Try it on a live sheet
| A | B | C | D | E | F | |
|---|---|---|---|---|---|---|
| 1 | Date | Name | Start | End | Break | Hours |
| 2 | Mon 2 Mar | Mara | 9:00 | 17:30 | 30 min | 8.00 |
| 3 | Mon 2 Mar | Jonas | 8:15 | 16:45 | 45 min | 7.75 |
| 4 | Tue 3 Mar | Mara | 9:30 | 18:00 | 30 min | 8.00 |
| 5 | Tue 3 Mar | Priya | 22:00 | 6:00 | 30 min | 7.50 |
| 6 | Wed 4 Mar | Jonas | 7:45 | 15:15 | 30 min | 7.00 |
| 7 | Wed 4 Mar | Priya | 21:30 | 5:30 | 45 min | 7.25 |
| 8 | Thu 5 Mar | Mara | 10:00 | 19:15 | 60 min | 8.25 |
| 9 | Fri 6 Mar | Jonas | 8:00 | 12:30 | 0 min | 4.50 |
F2 shows 8.00 for Mara's 9:00 to 17:30 shift with a 30-minute break. Priya's night shift from 22:00 to 6:00 in F5 shows 7.50: eight hours, minus 30 minutes.
Why it works
Works out (the result of MOD (step 1) times 24) minus (E2 divided by 60).
- 1. MOD: Gives the remainder after dividing
D2minusC2by1. - 2. Put together: Puts it together: (the result of step 1 times
24) minus (E2divided by60).
As hours and minutes instead of a decimal
Keep the result as a time and format the cell as [h]:mm: =MOD(D2-C2,1)-E2/1440. A day has 1,440 minutes, so the break in minutes divided by 1,440 is the break as a fraction of a day. The square brackets keep hours counting past 24 when you total a week.
=MOD(D2-C2,1)-E2/1440Without MOD, for day shifts only
=(D2-C2)*24-E2/60 works when every shift ends on the day it starts. For a night shift it gives a negative number, because 6:00 is smaller than 22:00.
=(D2-C2)*24-E2/60When you need it
Timesheets for payroll, invoices for hourly work, rota planning and overtime checks all need hours as a number that can be multiplied by a rate. A decimal result (8.25 hours) multiplies cleanly; a time result (8:15) needs converting first. Keep the break in its own column so it can differ per shift, and round the result only at the end if your payroll rounds to quarter hours. For overtime, compare the weekly total with the contracted hours using IF or MAX.
In Google Sheets
Google Sheets stores times as fractions of a day too, so the formula and MOD work the same way there.
Common mistakes
Multiplying by 24 but forgetting to turn the break into hours (minutes ÷ 60).
Totalling a week of times formatted
h:mm, which wraps after 24 hours; use[h]:mm.Leaving out MOD, so night shifts come out negative.
Sources
Official documentation the facts on this page were checked against.