Show you the step-by-step math

Written by

in

Calculating the difference between two dates in Power Automate is primarily achieved using the ticks() function or the dateDifference() function. Unlike Power Apps, Power Automate does not have a native DateDiff function, requiring a combination of actions and expressions to get results in days, hours, or minutes.

Here are the primary methods for calculating date differences: Method 1: Using dateDifference() (Recommended for Days)

This is the simplest way to get the difference between two dates in a days-hours-minutes format.

Expression: dateDifference(triggerOutputs()?[‘body/StartDate’], triggerOutputs()?[‘body/EndDate’]).

Notes: This function returns a string in the format d.hh:mm:ss. To isolate the days, you can use the split() function, e.g., split(dateDifference(…), ‘.’)[0]. Method 2: Using ticks() (Recommended for Hours/Minutes)

Ticks are 100-nanosecond intervals. Calculating the difference in ticks allows for precise conversion to any unit. Compose – Ticks 1: Use ticks(variables(‘StartDate’)). Compose – Ticks 2: Use ticks(variables(‘EndDate’)).

Calculate Difference: sub(outputs(‘Ticks2’), outputs(‘Ticks1’)). Conversion Formulae (Difference in Ticks): Seconds: div(sub(ticks2, ticks1), 10000000) Minutes: div(sub(ticks2, ticks1), 600000000) Hours: div(sub(ticks2, ticks1), 36000000000) Days: div(sub(ticks2, ticks1), 864000000000). Summary Table Days dateDifference() or Ticks \div 864000000000 Hours Ticks \div 36000000000 Minutes Ticks \div 600000000

If you are using data from SharePoint, you may need to ensure your date format is ISO 8601 (YYYY-MM-DDThh:mm:ssZ) before applying these formulas.

Need to calculate business days or exclude weekends? Let me know and I can provide a workflow to handle that!

Calculate the Difference Between Two Dates in Power Automate