cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Calculate duration between 2 date columns and show output in a new column in email

Hi, 

 

Below is the MS flow that I have been working on which spits out the all tasks with Start Date and Completion Date.

 

The flow is working as per my expectation

I am trying to add a new column to the email output which should calculate the duration between the Outage Start Date and Outage Completion Date columns. 

I am stuck as I couldn't find any formula/expression that can calculate the new column for me?

 

Can someone please guide me and tell how should I calculate the duration between two date columns and if there is anything that I need to modify in the current flow to make it work as I am totally new the MS Flow?

 

Flow.jpg

2 REPLIES 2
Highlighted
Super User II
Super User II

Re: Calculate duration between 2 date columns and show output in a new column in email

@PowerUserVir 

Hi there.  Check out this article on Date Math in Power Automate, Moving Targets.  It might be enough to get you started in the right direction.

 

Good luck!

-Ed

 

If you liked this reply, please give it a thumbs up! If this reply has answered your question or resolved your challenge, please consider marking it as a Solution. This helps other users find it more easily via search.

Highlighted
Frequent Visitor

Re: Calculate duration between 2 date columns and show output in a new column in email

Thanks, @edgonzales  for your direction.

 

I tried my workflow using your direction. Below is the new changed flow.

 

1. I have initialized the 'Date Created' and 'Date Completed' variables

2. Then based on the value received from the list tasks, I am trying to set the value of variables (Date Created and Date Completion) and calculating the ticks at the same time with the below expression:

ticks(items('Apply_to_each')?['createdDateTime'],864000000000)
 
3.  When setting up the Task Variable as part of 'Iterate through Tasks', I am calculating the difference between Date Created and Date Completion variables with below expression:
sub(variables('Date Completion'),variables('DateCreated'))
the output of which is getting assigned to the 'Total Outage Time'. Total Outage Time variable will show up the difference between the dates.
 
I am getting the highlighted ( in red) error when trying to execute the flow
 
Workflow.jpg
 
Would you be able to tell me the issue with my flow?

 

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

Join the new Power Virtual Agents Community!

We are excited to announce the launch of Power Virtual Agents Community. Check it out now!

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!

Top Solution Authors
Top Kudoed Authors
Users online (7,575)