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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Adding days to date un...
Power Automate
Answered

Adding days to date until certain date

(0) ShareShare
ReportReport
Posted on by

Hi all,

 

I want to create a loop that will run until dates passed from PowerApp: Date1 = Date2, lets say there is 3 days difference in date and for each date i want to create a new item on SharePoint list, how should i increment Date1 by 1 until it meets Date2 date?

 

As if im going to use adddays(date1,1) inside the loop it will never increment over date1+1 value

Categories:
I have the same question (0)
  • Ed Gonzales Profile Picture
    4,531 Most Valuable Professional on at

    @Anonymous 

    Hey there.  Check out a "Do Until" loop.  With that, you can basically do exactly what you're asking about by going until the two dates equal.

     

    Keep us posted.

    -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.

  • Verified answer
    rsaikrishna Profile Picture
    3,703 on at

    @Anonymous 

     

    Created a sample to address your requirement.

     

    Took 3 variables:

    varDateFromPowerApp : Assuming as value coming from PowerApps

    varDate2: Date value available locally to compare.

    varTempDate: For temporary usage in the flow.

     

    1.JPG

     

    Expressions in the below IF condition:

    Left value: formatDateTime(variables('varDateFromPowerApp'),'MM/dd/yyyy')
    Right value: formatDateTime(variables('varDate2'),'MM/dd/yyyy')
     
    2.JPG

     

    Here is the entire Do Until block:

    3.JPG

     

    Expressions in Do Until:

    Left value: formatDateTime(variables('varTempDate'), 'MM/dd/yyyy')
    Right Value:  formatDateTime(variables('varDate2'),'MM/dd/yyyy')
     
    Compose action Expression:
    addDays(formatDateTime(variables('varTempDate'),'MM/dd/yyyy'),1)
     
    Please review the above flow and let me know if you have any questions.
     
    Regards
    Krishna Rachakonda
    If my reply helped you solving the issue, please mark the reply as Accepted Solution.
     
  • ScottShearer Profile Picture
    25,270 Most Valuable Professional on at

    @Anonymous 

    The solution proposed by @rsaikrishna will likely work for you.  However, you'll want to put a Delay action inside of the loop and set it to a one day delay.  Otherwise, the loop will just run continuously a few times and create a few SharePoint items within a few seconds.

    Also, you'll want to click on "Change limits" inside of the Do Until loop.  The default for the loop is to run for the lesser of 60 loops or 1 hour(it shows as PT1H).  You'll want to change it so that it will run for a number of days.  For example, to run for 7 days, set the time out to P7D. Also ,remember that a Flow can run for a maximum of 30 days.

     

    image.png

     

  • Community Power Platform Member Profile Picture
    on at

    @ScottShearer Thanks for your tips! I actually do want to create separate entries on my list 🙂

     

    @rsaikrishna that worked perfectly! Thanks!

  • Julien Groud Profile Picture
    on at

    Thanks for sharing your answer and feedback.

  • leipapuu1 Profile Picture
    14 on at

    Help needed and much appreciated...

     

    I was happy to find this post, as I was facing simimlar question. However, for some reason the solution is not working for me.

     

    I have a flow that sends a Forms pro survey invite to a contact. If the contact does not answer before set reminder date (7 - 14 days after) is reached, the flow will send him/her a reminder email. I am trying to use Do Until step to create a wait-condition similar to old workflows: wait until a date field is passed. Giving users the possibility to update the date field manually while the waiting period is on. The Do-Until-step simply won't react to my condition, even though the previous Compose-step shows it is true.

     

    I also tried to use this in the Do-Until-step, it didn't work either:

    @equals(greaterOrEquals(formatDateTime(addDays(utcNow(), 1), 'yyyy-MM-dd'), formatDateTime(variables('ReminderDate'), 'yyyy-MM-dd')), true)

     

    The part of the flow looks like this:

     DoUntil_for_Date_not_working.png

     

    The test run looks like this, and stays like this until the flow stops (due to timeout) in an hour or so.

    TestRun_for_flow_DoUntil_not_working.png

     

  • leipapuu1 Profile Picture
    14 on at

    This problem was elsewhere and I solved it. 

     

    I was using the data queried in the do-until-step after the step. This is obviously not allowed. That caused the problem in my case. So the date comparison clauses are ok and works with the do-until-step.

     

    I do think that it is quite difficult to debug the do-until-step. It took me 3 days to understand, what is the problem since the workflow instance logic is hidden until all the delays are completed.

  • Gyllentid Profile Picture
    894 on at

    Hi @rsaikrishna  we followed your step by step. It works for us. However it is not giving the last date. Out of 5 whole days from start to finish, the output is 1st day, 2nd day, 3rd day, 4th day. The 5th day, which is the same as the end date, is not being created. Any ideas? We use the "is equal to" in the condition...

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard