Is it possible to calculate date differences in Microsoft Flow? See example below for calculating the date differences and getting regular and/or work days.
Duration: 7 days
Duration: 5 days
I'm afraid there is no direct action or Expression to calculate date differences between two dates and get regular and work days.
But you can try this method:
First list all the dates between the two dates, then store in the array
You could first create a flow through such a link, get all the dates between the two dates, and store them in an array.
Then by traversing the array, use dayofweek() function to determine which value the date is equal to, 0 for Sunday, and 6 for Saturday, so you can get the number of days on the weekend and get workdays.
You could follow the following method to traverse the array and get the corresponding Regular Days, weekdays, workdays:
Condition formula reference:
@or(equals(dayOfWeek(items('Apply_to_each')), 0),equals(dayOfWeek(items('Apply_to_each')), 6))
Compose action-Regular Days Expression:
Compose action-WorkDays Expression:
Note: Since Do Until can only be executed 60 times, this method is limited to a date of 60 days or less.
The flow works successfully as below, start date 09/10/2018 ,end date 09/25/2018:
Please take a try.
Also you could post this idea in the Flow Ideas forum, so it might be considered for future releases.
I've discovered the solution to this issue for another user here on the community, and I have written a blog article that explains the solution in detail. Check it out here:
If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
I would like to ask if this solution is still working because I am folliwing this instructions step by step, but I am unable to get it working. Every time I get the same mistake, when The flow tries to Append to array variable:
BadRequest. The variable 'DateArray' of type 'Array' cannot be initialized or updated with value '09/11/2018' of type 'String'. The variable 'DateArray' only supports values of types 'Array'.
I would appreciate any advice.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
Did you know that you could restore a deleted flow? Check out this helpful article.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
At the monthly call, connect with other leaders and find out how community makes your experience even better.