cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
livingstonep
Kudo Kingpin
Kudo Kingpin

Problem calculating dateDiff in flow expression

I am sending an email with the number of days remaining before a flow approval will timeout- which has a maximum of 30 days

 

So I am trying to use

 

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

 

 

and this should be showing something like 7 days or10 days

 

Unfortunately, it's coming up with number like 53 days even though the Modified date is 2020-01-13 so 30 days - 23 should equal 7 days

 

So how should I be calculate that?

1 ACCEPTED SOLUTION

Accepted Solutions
abm
Super User
Super User

Hi @livingstonep 

 

Your expression is wrong

 

Use the below

 

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

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

View solution in original post

2 REPLIES 2
abm
Super User
Super User

Hi @livingstonep 

 

Your expression is wrong

 

Use the below

 

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

 

Thanks

 



Did I answer your question? Mark my post as a solution!

If you liked my response, please consider giving it a thumbs up


Proud to be a Flownaut!

Learn more from my blog
Power Automate Video Tutorials

Can you check the date format of the 

items('Apply_to_each')?['Modified'])

 The format of the dates will need to match. So something like this: 2020-01-20T10:20Z

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,518)