How to Get the Remainder of a Division in Power Apps with Mod
Mod returns what's left over after a division. Mod(450, 60) is 30: 450 minutes is seven whole hours with 30 minutes left over. Together with RoundDown for the whole hours, it turns a number of minutes into hours and minutes.
The example is the Overtime Timesheet app, which shows the hours of each shift as, for example, 7 h 30 min.
Syntax
Mod(Number, Divisor)
- Number is the number to divide, and Divisor the number to divide by.
- The result has the same sign as the divisor (Mod function).
Microsoft's examples:
| Formula | Result |
|---|---|
Mod(25, 4) | 1 |
Mod(25, -4) | -3 |
Mod(-25, -4) | -1 |
Mod(-25, 4) | 3 |
Step 1: Get the Minutes Left Over
I put the formula into a text control's Text for a moment, so Studio's preview strip shows the result:
Mod(450, 60)
450 divided by 60 is 7, with 30 left over:

Step 2: Pair It with the Whole Hours
Mod gives only the part left over. The whole hours come from dividing and rounding down: RoundDown(450 / 60, 0) is 7 (How to Round a Number in Power Apps with Round, RoundDown and RoundUp). Together they make 7 h 30 min: How to Convert Minutes to Hours and Minutes in Power Apps.
How the Example Uses It
The app uses Mod twice.
The hours line on the Log overtime screen splits the minutes worked:
$"Hours worked: {Text(Minutes / 60, "0.00")} ({RoundDown(Minutes / 60, 0)} h {Mod(Minutes, 60)} min)"
And the list of times people pick from turns a number of minutes since midnight into a time of day: the hour from RoundDown, the minute from Mod (How to Let Users Pick a Time in Power Apps):
TimeChoices = ForAll(Sequence(288, 0, 5), Time(RoundDown(Value / 60, 0), Mod(Value, 60), 0));
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
| Using Mod for the whole hours | You get the minutes left over, not the hours | RoundDown(minutes / 60, 0) for the hours |
| Swapping the arguments | The divisor becomes the number being divided | The number first, the divisor second |
| Expecting a negative result for a negative number | The sign follows the divisor: Mod(-25, 4) is 3 | Keep the minutes 0 or more, for example with Max(0, …) |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The minutes are larger than 59 | The divisor isn't 60 | Mod(minutes, 60) |
| The minutes look wrong for a negative total | Mod follows the divisor's sign | Stop the total going below 0 before splitting it |
FAQ
Does Excel have the same function?
Yes, MOD. The old Excel timesheet the app replaces used it to wrap overnight shifts round the clock: How to Calculate Hours for an Overnight Shift in Excel with MOD.
How do I check whether a number is even?
Mod(n, 2) = 0 is true when n divides by 2 with nothing left over.
Conclusion
Mod(Number, Divisor) is what's left after dividing. With 60 as the divisor it's the minutes past the whole hours, and with RoundDown for the hours it splits any number of minutes.
Additional Resources
- Mod function: syntax, the sign rule and examples.
