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 / Incrementing a DateTim...
Power Automate
Suggested Answer

Incrementing a DateTime Variable within a Do Until Loop

(0) ShareShare
ReportReport
Posted on by 37
I have a Do Until loop where I want to add 1 day to a variable 'CurrentDate', which has been initialized outside of the loop. I am using the Set Variable with addDays() to add the day to the CurrentDate variable, but when I save the flow, I get the following error:
 
Flow save failed with code 'WorkflowRunActionInputsInvalidProperty' and message 'The inputs of workflow run action 'Set_variable' of type 'SetVariable' are not valid. Self reference is not supported when updating the value of variable 'CurrentDate'.'.
 
Any ideas on what I am doing wrong?
Categories:
I have the same question (0)
  • Suggested answer
    AndrianaO Profile Picture
    213 Moderator on at
    Hi! Unfortunately, you cannot use self-reference inside the addDate() function, but I have an idea for you.

    How about using an additional integer variable called NumberOfDays? You need to initialize it outside the loop with a zero initial value. Then you can increment it inside the loop using the "Increment variable" action. After that, you can use the "Compose" action to add this incremented number of days to your CurrentDate. The formula in Compose action:
     
    addDays(variables('CurrentDate'),variables('NumberOfDays'))
     
     My test flow looks as follows:
     
     
    Let me know if this works for you!

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 519 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 296 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard