Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Answered

Count days between to dates

(0) ShareShare
ReportReport
Posted on by

Hello,

I am quite new to Power Automate.
I need to get the difference between two dates and see, if it is more than 365. If so I want to do something otherwise I just do nothing.

I found this post:

https://powerusers.microsoft.com/t5/Building-Flows/Number-of-days-between-two-Dates/td-p/281578

 

and think this might be very helpful:

div(sub(ticks('2019-05-13'),ticks('2019-05-04')),864000000000)

 

Now my problem is to fill the date within the ticks-formula.
For the first date I use utcNow() which at least does not lead to a syntax error.

However I have difficulties setting the second date.
I tried to put it in a variable called "nextTermin".

So my expression looks like this:

 

 

 

div(sub(ticks('utcNow()'),ticks(variables('nextTermin')),864000000000)

 

 


 However Power Automate says the expression is invalid.
I also tried to put the string within the second ticks in quotation marks - ticks('variables('nextTermin')' but this does not work either.

Any help very appriciated.

Thank you!

  • RK-23070616-0 Profile Picture
    on at
    Re: Count days between to dates

    oh my god thank you! I didn´t see the missing ).
    This seems to work now thank you all!

  • Verified answer
    tom_riha Profile Picture
    10,127 Most Valuable Professional on at
    Re: Count days between to dates

    I just checked the expression in editor, it's invalid because it's missing closing ) to close the div() expression.

    div(sub(ticks(utcNow('yyyy-MM-dd')),ticks(formatDateTime(variables('nextTermin'),'yyyy-MM-dd')),864000000000))

     

  • RK-23070616-0 Profile Picture
    on at
    Re: Count days between to dates

    hm, but the one date could be 31.12.2020 and the other could be 01.01.2021 - so the years are different but it is much less than 365 days.

  • RK-23070616-0 Profile Picture
    on at
    Re: Count days between to dates

    The original value is a date.
    But I cannot assign type date to the variable so I choose String... that´s not ok I guess now.
    The value is 01.01.2021 (german date)

  • RK-23070616-0 Profile Picture
    on at
    Re: Count days between to dates

    oh, thank you. That´s of course not what I want.
    But then the problem is that if I remove the apostrophes it says again that the expression is invalid 😞

  • tom_riha Profile Picture
    10,127 Most Valuable Professional on at
    Re: Count days between to dates

    Hello @der_cosmicyes ,

    you shouldn't have the apostrophes around utcNow(). These tell the Power Automate that the content inside ' ' is a string = it'll not use the utcNow() as an expression, but as utcNow() text. Try to remove them.

    div(sub(ticks(utcNow()),ticks(variables('nextTermin')),864000000000)

    And maybe you'll need to convert both dates into the same format as in the example you shared.

    div(sub(ticks(utcNow('yyyy-MM-dd')),ticks(formatDateTime(variables('nextTermin'),'yyyy-MM-dd')),864000000000)

     

  • krootz Profile Picture
    458 on at
    Re: Count days between to dates

    @der_cosmicyes what's the type of variable 'nextTermin'? and can you share the value here? alternatively, if you just want to check if it's more than 365, I would just compare the year if they are not equal using formatdatetime().

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard >