[TIPS] Calculate the time/date difference in Power Automate / Flow
Power Automate has an expression called ticks(…). This expression will take a date and calculate the number of ticks for that date. One tick is 100 nanoseconds, starting with the 1st of January 0001 00:00:00.
When you calculate a difference between two dates / times, you must get ticks for both of the dates, e.g.
Date1 - Date2
sub(ticks(Date1), ticks(Date2))
Convert ticks into more readable unit
The result of the subtraction should be then converted into a more understandable number. Use the div(…) expression to divide the number by a number representing the desired unit.
Divide by | To get |
---|---|
864000000000 | days |
36000000000 | hours |
600000000 | minutes |
10000000 | seconds |
For example, to get the number of minutes between Date1 and Date2:
div(sub(ticks(Date1), ticks(Date2)),600000000)
it was so helpful for me , thx
ReplyDelete