How to Calculate the Minutes Between Two Times in Power Apps with DateDiff
DateDiff measures the time between two dates or times, as a whole number of the unit you ask for. Ask in hours, and 17:00 to 20:30 is 3: the half hour is lost. Ask in minutes, get 210, and divide by 60 for 3.5 hours.
The example is the Overtime Timesheet app, which counts the minutes of every shift with DateDiff.
Syntax
DateDiff(StartDateTime, EndDateTime [, Units])
- The start comes first and the end second; the other way round gives a negative number.
- Units is a TimeUnit, such as Minutes or Hours. Leave it out and you get Days.
- The result is a whole number of units (DateAdd, DateDiff, and TimeZoneOffset functions).
Example 1: Minutes
I put each formula into a text control's Text for a moment, so Studio's preview strip shows the result:
DateDiff(DateTime(2026, 11, 6, 17, 0, 0), DateTime(2026, 11, 6, 20, 30, 0), TimeUnit.Minutes)
17:00 to 20:30 is 210 minutes:

Example 2: Hours Lose the Minutes
The same two times in TimeUnit.Hours:
DateDiff(DateTime(2026, 11, 6, 17, 0, 0), DateTime(2026, 11, 6, 20, 30, 0), TimeUnit.Hours)
The answer is 3, not 3.5:

Microsoft's own example does the same: 09:45:00 to 10:15:36 is 1 in hours, because the minutes/seconds are ignored.
Example 3: Minutes Divided by 60
For hours with the minutes kept, count minutes and divide:
DateDiff(DateTime(2026, 11, 6, 17, 0, 0), DateTime(2026, 11, 6, 20, 30, 0), TimeUnit.Minutes) / 60

Microsoft's page recommends exactly this: use a smaller unit, and convert the result appropriately.
How the Example Uses It
The app counts each shift's minutes in a user-defined function, from the start and finish it builds with DateTime:
ShiftMinutes(ShiftDate: Date, StartAt: Time, EndAt: Time): Number =
DateDiff(ShiftStart(ShiftDate, StartAt), ShiftEnd(ShiftDate, StartAt, EndAt), TimeUnit.Minutes);
Minutes are also what the break is measured in, so the hours worked are (ShiftMinutes(...) - break) / 60. Across the night the clocks change, DateDiff counts the real time: How to Calculate Hours Across a Daylight Saving Time Change in Power Apps.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
TimeUnit.Hours for hours worked | Part hours are dropped: 3 instead of 3.5 | Minutes divided by 60 |
| Leaving out the units | You get days | Pass TimeUnit.Minutes |
| End first, start second | A negative number | Start first |
Subtracting the two values with - | Microsoft advises DateDiff instead | Use DateDiff |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The hours are a whole number | The unit is Hours | Use Minutes and divide by 60 |
| The result is negative | The start and end are swapped, or the end is on the wrong day | Check the order, and the end's date for night shifts |
| An overnight shift comes out negative | The finish was put on the start day | Move the finish to the next day: How to Calculate Hours for an Overnight Shift in Power Apps |
FAQ
How do I show the result as hours and minutes?
Split the minutes with RoundDown and Mod: How to Convert Minutes to Hours and Minutes in Power Apps.
Does DateDiff work on times without dates?
Yes; Microsoft's own example uses two times from TimeValue. A shift that crosses midnight needs dates, though, or the finish is earlier than the start.
Conclusion
DateDiff(start, end, TimeUnit.Minutes) counts whole minutes between two moments. Divide by 60 for hours, and keep the start first.
Additional Resources
- DateAdd, DateDiff, and TimeZoneOffset functions: units, whole-number results and fractional hours.
