AutomateAlong

How-tos › Dates

How to calculate the number of days between two dates in Power Automate

Updated 2 November 2026

The expression:

div(sub(ticks(items('Apply_to_each')?['DueDate']), ticks(utcNow())), 864000000000)

The gap between two dates in ticks, divided by the ticks in a day (864,000,000,000). Negative means overdue.

Where it goes

Messages, or a Condition (is less than 3).

  1. In the Power Automate designer, click in the box that needs the value.
  2. Select the fx (Expression) button that appears next to the dynamic content list.
  3. Paste the expression and select Add. It should appear as a purple fx chip; if you can see it written out as text, it went in as plain text and won't run.

Example output

3 (illustrative; AutomateAlong doesn't run expressions)

The common mistake

sub(items('Apply_to_each')?['DueDate'], utcNow())

sub() only works on numbers, so this fails with 'expected Integer or Float'. Convert both dates with ticks(), subtract, then divide by the ticks in a day.

Before you rely on it

  • Whole days, rounded towards zero.

Change it for your flow

Step names inside an expression must match your steps exactly, with underscores for spaces: Get_items, not Get items. To adapt it, open it in the Expressions checker, which points at any bracket, quote or name that's wrong and suggests the corrected version. To write a different one from plain English, describe what you need on the same page.

Related

AutomateAlong is independent and isn't affiliated with Microsoft. Microsoft and Power Automate are trademarks of the Microsoft group of companies.