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

Notifications

Announcements

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,185 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,185 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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 503 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 321 Moderator

#3
abm abm Profile Picture

abm abm 237 Most Valuable Professional

Last 30 days Overall leaderboard