formulastreak

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

Two of the shifts end after midnight; MOD keeps their hours positive · edit F2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultF2 = 8.00
ABCDEF
1DateNameStartEndBreakHours
2Mon 2 MarMara9:0017:3030 min8.00
3Mon 2 MarJonas8:1516:4545 min7.75
4Tue 3 MarMara9:3018:0030 min8.00
5Tue 3 MarPriya22:006:0030 min7.50
6Wed 4 MarJonas7:4515:1530 min7.00
7Wed 4 MarPriya21:305:3045 min7.25
8Thu 5 MarMara10:0019:1560 min8.25
9Fri 6 MarJonas8:0012:300 min4.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. 1. MOD: Gives the remainder after dividing D2 minus C2 by 1.
  2. 2. Put together: Puts it together: (the result of step 1 times 24) minus (E2 divided by 60).

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/1440

Without 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/60

When 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.

Practise MOD on a live sheet

Lesson 29, Hours and times (Unit 7, Dates and time maths), has 7 graded exercises, checked instantly, with steps and hints when you're stuck. Pro