D365 / Power Platform blog

Home » How-To » Flow » Do Until with dates in Power Automate

In this post, I will show you how to use the “Do Until” functionality in Power Automate with dates.

  1. We will start by creating a Instant cloud flow with a manually trigger.

2. We will add our first step, which is going to be our “From Date”. For this, we are using the “Initialize variable” block.
I am writing the date in this format: yyyy-MM-dd, you can use whatever format fits you best (I will show down in this post how you could modify it to fit your format).

3. Next up we will create another variable, which will contain our “To Date”. This is going to be similar to our last block, but with “To Date” as the name. (I really recommend setting proper namings on blocks used in Power Automate, and not leaving as default “Initialize variable”)


4. Now we are going to initialize the variable which will contain our “dynamic date”, which will change every time we run through the “Do Until” loop at the end of the flow. The value of this could just be left as empty.

5. Now we need to create a condition, this is to check if our FromDate is less than our ToDate, otherwise there is nothing to loop. For this we use expressions, to format our FromDate to Date Format.
formatDateTime(variables(‘FromDate’),’yyyy-MM-dd’)
If you are using another format, please update this expression with your DateTime format.

Then we will update the condition with “is less than” and then we will add an expression for the ToDate variable.
formatDateTime(variables(‘ToDate’),’yyyy-MM-dd’)
Also here you will need to change the format, to fit your format of need.

6. Now that we have our condition set up, we could add some actions inside. If no should be empty (for this example), and into the “if yes” we could add a block of “Set Variable”. We will choose our “Dynamic Date” variable, add set the value to “FromDate”.

7. Once you have set a value into the “Dynamic Date” variable, we could add a “Do Until” block and add a condition to it. We will run the “Do Until” loop until DynamicDate is equal to “To Date”.

NB! Under “Change limits” you could change the max amount of runs the “Do Until” loop could do. If you know you are going to loop through a couple of years it could be great to increase this amount to fit whatever your needs are. This will only loop through maximum 60 days from your “From Date”

8. Inside this “Do Until” loop, you are able to add some actions and use your dynamic date variable. In this post, I will not cover what exact to use the dynamic date to, but I will demonstrate by printing our date to a row in Excel.
I’ve created an excel document with a table named “dates”. Now I add the “Add a row into a table” action and add our “DynmicDate” variable like this

9. Add a “Compose” action and add the following expression:
addDays(variables(‘DynamicDate’), 1, ‘yyyy-MM-dd’)
You could change this format, after your needs. The importance is that the format is similar to the other date formats in the flow.

10. Last, we need to update the DynamicDate variable with our latest date, which is our entry date + 1 day.

Now you could run your flow and see the excel table gets populated with dates within the “FromDate” and “ToDate”.

Thanks for reading this post, any questions please contact me or comment on this post.

Share this post

Scroll to Top