cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kosenurm
Super User
Super User

Auto increment a date in Power Automate

Hi there,

 

I have a Desktop flow which runs a VS Code (Powershell) script in the night via unattended RPA add-on, takes the output file and uploads it to OneDrive for Business. This works all good.

 

However, in the VS Code script, there are date parameters for the script we are running of

 

start-date: 2022-04-11
end-date: 2022-04-20

 

Is there a way I can tell the Desktop flow to increment each of the above dates by one day every time it runs?

 

Thanks

K.

1 ACCEPTED SOLUTION

Accepted Solutions
Pavel_NaNoi
Continued Contributor
Continued Contributor

A quick trick you can pull off is to first set a date to one just before the current date and then use the "Get Current date and Time" action, subtract those dates using the "Subtract Dates" action which will give you their difference and then simply add the subtracted days into your dates above using the "Add to datetime" action.

 

Now what this will do is the following: Once it runs it will find the difference between the current date and the date you've set, this will be added onto your dates, once the next day occurs the automation will once again find the difference between the current date and the fixed date you've set, but the current date has changed by 1 day, thus your dates will now be increased by 2, and this will repeat infinitely, adding 1 day difference each time a day passes.

 

Other than that you could probably get something to work using Power Automate if you can use that.

 

Hope this helps!

View solution in original post

1 REPLY 1
Pavel_NaNoi
Continued Contributor
Continued Contributor

A quick trick you can pull off is to first set a date to one just before the current date and then use the "Get Current date and Time" action, subtract those dates using the "Subtract Dates" action which will give you their difference and then simply add the subtracted days into your dates above using the "Add to datetime" action.

 

Now what this will do is the following: Once it runs it will find the difference between the current date and the date you've set, this will be added onto your dates, once the next day occurs the automation will once again find the difference between the current date and the fixed date you've set, but the current date has changed by 1 day, thus your dates will now be increased by 2, and this will repeat infinitely, adding 1 day difference each time a day passes.

 

Other than that you could probably get something to work using Power Automate if you can use that.

 

Hope this helps!

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Kudoed Authors
Users online (3,334)