formulastreak

Maths function

MOD function in Google Sheets and Excel

MOD returns the remainder after dividing one number by another, with the same sign as the divisor.

Checked against Microsoft's and Google's documentation on · Example calculated on a live sheet

Syntax

MOD(number, divisor)

Arguments in [brackets] are optional. Google Sheets writes it MOD(dividend, divisor).

Example

=MOD(D2-C2,1) reads: Subtract the start time in C2 from the end time in D2, and keep only the part of a day that's left over, so an overnight shift isn't negative.

Weekly timesheet · edit F2 and watch it recalculate
Click a cell (or use the arrow keys) to insert its address · Enter shows the resultF2 = 8:30
ABCDEF
1DateNameStartEndBreakDuration
2Mon 2 MarMara9:0017:3030 min8:30
3Mon 2 MarJonas8:1516:4545 min8:30
4Tue 3 MarMara9:3018:0030 min8:30
5Tue 3 MarPriya22:006:0030 min8:00
6Wed 4 MarJonas7:4515:1530 min7:30
7Wed 4 MarPriya21:305:3045 min8:00
8Thu 5 MarMara10:0019:1560 min9:15
9Fri 6 MarJonas8:0012:300 min4:30

F2 shows 8:30 as before, and F5 now shows 8:00 for Priya's 22:00–06:00 shift, where plain subtraction would give −16 hours.

How the spreadsheet calculates it

Gives the remainder after dividing D2 minus C2 by 1.

  1. 1. MOD: Gives the remainder after dividing D2 minus C2 by 1.
    • number = `D2-C2`: the value to wrap
    • divisor = `1`: `1`

More MOD examples

  • =MOD(10,3)1: ten divided by three leaves one.
  • =MOD(D2-C2,1)*24A shift's length in decimal hours, overnight included.
  • =IF(MOD(A2,2)=0,"Even","Odd")Whether the number in A2 is even or odd.
  • =INT(B2/60)&"h "&MOD(B2,60)&"m"Minutes in B2 written as hours and minutes.

Paste any of these into the formula explainer to see it step by step.

Tips

  • With times, divide by 1: the remainder is the time of day without whole days.
  • Use INT for the whole part and MOD for the rest: 135 minutes is INT(135/60) hours and MOD(135,60) minutes.
  • Format time results as h:mm, or multiply by 24 for decimal hours.

What MOD is used for

Shift lengths that cross midnight, splitting minutes into hours and minutes, even/odd checks, repeating patterns like every third row, and cycles such as rota days.

Arguments

ArgumentRequiredWhat it is
numberYesThe number to divide, or a calculation like D2-C2.
divisorYesWhat to divide by. With times, 1 means one whole day.Watch out: A divisor of 0 gives #DIV/0!.

Common mistakes

  • Wrapping only the start or the end: wrap the whole difference.

  • Expecting a negative result from a negative number: MOD(-3,2) is 1, because the result takes the divisor's sign.

  • Formatting an overnight-shift result as a number and seeing 0.33: time results need a time format like h:mm.

In Google Sheets

Google Sheets has MOD(dividend, divisor): the same two arguments under different names, so the overnight-shift formula is written the same way in both apps.

Errors you may see with MOD

  • #DIV/0!: The divisor is 0 or an empty cell.
  • #VALUE!: One of the arguments is text that isn't a number.

Questions

How do I calculate hours worked across midnight?

Wrap the difference: MOD(end-start,1). For 22:00 to 06:00 it gives 8:00, where plain subtraction gives a negative time.

How do I check if a number is even?

MOD(A2,2)=0 is TRUE for even numbers; MOD(A2,2)=1 for odd ones.

How do I highlight every other row?

Use MOD(ROW(),2)=0 as a conditional formatting rule: it's TRUE on every even row.

How do I turn minutes into hours and minutes?

Divide by 60 for the hours and keep the rest with MOD: for 135 minutes, INT(135/60) is 2 and MOD(135,60) is 15, so 2h 15m.

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