web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Count days between to ...
Power Automate
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!

Categories:
I have the same question (0)
  • krootz Profile Picture
    458 on at

    @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().

  • tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    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)

     

  • RK-23070616-0 Profile Picture
    on at

    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 😞

  • RK-23070616-0 Profile Picture
    on at

    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

    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.

  • Verified answer
    tom_riha Profile Picture
    10,187 Most Valuable Professional on at

    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

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

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

Season of Sharing Community Challenge Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Valantis Profile Picture

Valantis 484

#2
11manish Profile Picture

11manish 282

#3
David_MA Profile Picture

David_MA 280 Super User 2026 Season 1

Last 30 days Overall leaderboard