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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / How to efficiently cal...
Power Automate
Unanswered

How to efficiently calculate date values between two given dates? Do until block is slow.

(1) ShareShare
ReportReport
Posted on by 2

Hello community.

 

Right now im struggling to efficiently calculate date values between two given dates. Let me explain:

In my flow I'm getting items from a SharePoint list, there can be thousands of items in this list.

Each item has a column for "start date" and a column for "end date".

 

My task is to write one line into an XLSX or CSV file for each date in between start and end date.

 

Example: Start date of the item is March 1st, end date of the item is March 4th.

My final XLSX or CSV file needs to look like that:

 

"03-01-2021, Title of the item, Some other column value of the item, yet another column value of the item"

"03-02-2021, Title of the item, Some other column value of the item, yet another column value of the item"

"03-03-2021, Title of the item, Some other column value of the item, yet another column value of the item"

"03-04-2021, Title of the item, Some other column value of the item, yet another column value of the item"

 

Right now my approach is that im subtracting the start date from the end date to find out how many days are between those. I save this value in a variable called "daysBetweenStartAndEnd". I then use a "Do until" block which increases a counter from 0 until it reaches the "daysBetweenStartAndEnd" variable value. Within the Do until block im using the "Add to time" block to add the current counter value to the start date, like so:

 

03-01-2021 + counter value 0 = 03-01-2021

03-01-2021 + counter value 1 = 03-02-2021

03-01-2021 + counter value 2 = 03-03-2021

03-01-2021 + counter value 3 = 03-04-2021

Done.

 

I'm saving each calculated date value into an array for later use.

 

dountil.jpg

 

This works and results in the desired outcome, but it's slow.

 

As I said, my list can have thousands of items and the start and end date of those tend to be separated by hundreds of days, meaning for each item I will run through the Do until hundreds of times. For one single item with about 200 days in between, the Do until block takes like 3 minutes already. I even removed the Add to time block and the Append to array block for testing purposes (making the Do until do basically nothing), and it still took 2 minutes for this item. So running through a blank Do until seems to be very time consuming.

 

Is there any way I can make this more efficient? Any other approach I can try?

 

Thank you very much.

 

Categories:

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Automate

#1
Mohsin Ali Profile Picture

Mohsin Ali 414

#2
11manish Profile Picture

11manish 331 Super User 2026 Season 2

#3
M Bilal Khan Profile Picture

M Bilal Khan 274

Last 30 days Overall leaderboard