Skip to main content

How to Calculate the Minutes Between Two Times in Power Apps with DateDiff

· 5 min read
Jagdish Kumawat
Founder @ Dewiride

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​

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:

Any text control → Text
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:

The formula bar with DateDiff from 17:00 to 20:30 on 6 November 2026 in TimeUnit.Minutes, the preview strip reading 210 with Data type number, and the text control showing 210

Example 2: Hours Lose the Minutes​

The same two times in TimeUnit.Hours:

Any text control → Text
DateDiff(DateTime(2026, 11, 6, 17, 0, 0), DateTime(2026, 11, 6, 20, 30, 0), TimeUnit.Hours)

The answer is 3, not 3.5:

The formula bar with the same DateDiff in TimeUnit.Hours, the preview strip reading 3 with Data type number, and the text control showing 3

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:

Any text control → Text
DateDiff(DateTime(2026, 11, 6, 17, 0, 0), DateTime(2026, 11, 6, 20, 30, 0), TimeUnit.Minutes) / 60

The formula bar with the DateDiff in minutes divided by 60, the preview strip reading 3.5 with Data type number, and the text control showing 3.5

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:

App → Formulas
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​

MistakeWhat happensDo this instead
TimeUnit.Hours for hours workedPart hours are dropped: 3 instead of 3.5Minutes divided by 60
Leaving out the unitsYou get daysPass TimeUnit.Minutes
End first, start secondA negative numberStart first
Subtracting the two values with -Microsoft advises DateDiff insteadUse DateDiff

Troubleshooting​

SymptomLikely causeFix
The hours are a whole numberThe unit is HoursUse Minutes and divide by 60
The result is negativeThe start and end are swapped, or the end is on the wrong dayCheck the order, and the end's date for night shifts
An overnight shift comes out negativeThe finish was put on the start dayMove 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​