cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
maheshkhisteLiv
Level: Powered On

Calculating the difference between two date/times in Flow compose with dynamic values

Inside apply each (which contains Sp List items)  , i would like to calculate date difference. Scenario is 

expiray date (column of SP list item ) minus today's date is it equal to 90 days (this is again valye of list item field , will be dynamic value).

I tried many ways but doesn't seems to be working. I tried adddays but it takes integer as 2nd parameter , i tried to use dateDiff but doesn;t seems valid for MS flow.

 

Any help is aprreciated !

2 REPLIES 2
Community Support Team
Community Support Team

Re: Calculating the difference between two date/times in Flow compose with dynamic values

Hi @maheshkhisteLiv,

 

Could you please share a screenshot of your flow's configuration?

Do you want to filter SharePoint list items where expiry date minus today's date is equal to 90?

 

It is not simple to calculate the difference between two date/times in Microsoft Flow currently, if you want to filter SharePoint list items where expiry date minus today's date is equal to 90, you could consider take a try with following workaround as an alternative way:

 

I have created a SharePoint list on my side and the data structure of it as below:2.JPG

Note: The expiry date column is a Date type column in my SharePoint list.

 

I have made a test on my side and please take a try with the following workaround:

  • Add a "Recurrence" trigger, Interval set to 1 and Frequency set to Day.
  • Add a "Get items" action, specify Site Address and List Name.
  • Add a "Apply to each", input parameter set to output of "Get items" action.
  • Within "Apply to each" action, add a Condition, left input box set to following formula:

 

formatDateTime(addDays(utcNow(), 90), 'yyyy-MM-dd')

3.JPG

 

right input box set to expiry date dynamic content of "Get items" action, within middle drop down, choose is equal to.

 

 

 

Or you could consider take a try to click "Edit in advanced mode", then type the following formula:

 

@equals(formatDateTime(addDays(utcNow(), 90), 'yyyy-MM-dd'), items('Apply_to_each')?['expiry_x0020_date'])

5.JPG

 

 

Within "If/yes" branch of Condition, add a "Send me an email notification" action.

 

Image reference:4.JPG

The flow works successfully as below:6.JPG

 

 

In addition, the dateDiff() function is not supported in Microsoft Flow currently, if you would like this feature to be added in Microsoft Flow, please submit an idea to Flow Ideas Forum:

https://powerusers.microsoft.com/t5/Flow-Ideas/idb-p/FlowIdeas

 

More details about using expression within flow actions, please check the following article:

Use expression within flow actions

 

 

Best regards,

Kris

 

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
wcsmith
Level: Powered On

Re: Calculating the difference between two date/times in Flow compose with dynamic values

I did read that information, but not seeing anything that's specifically related to dates.  So one thing that works is wrapping my field in 'year ( date )'...so it clearly understands that my field is a date.  Am I to assume at this point that the FLOW language doesn't know how to format the dates?  This is a huge impact to our process...so just making sure before I reach this conclusion.

Helpful resources

Announcements
firstImage

New Ranks and Rank Icons in April

Read the announcement for more information!

firstImage

Better Together Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Community Summit North America

The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (2,314)