cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Issue with AddToTime

I am dynamically patching rows into a SQL table based on how many months there are between a starting date and ending date. I've got almost everything working nicely except for the AddToTime calculation in Flow.

 

This is my current formula that runs in a loop until the counter hits the required number of months: 

addToTime(variables('startingMonth'), variables('counter'), 'Month') 

 

I want the entry to be the first of every month. I pass in startingMonth as a date that is the first of a month. It seems adding a month only adds 4 weeks though... which is kind of understandable, but this screws me up in the month of June. One entry is for 6/1/2019, and the next is for 6/29/19. 

 

There is a function in PowerApps called DateAdd() that works as I desire, but I'm not able to dynamically build a table with looping in PowerApps, so I need to build it in Flow.

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Issue with AddToTime

@silkwire 

This shouldn't be hard.......

Please see my screen shots below.  I could have combined all of my variables into one really ugly nested expression but I left as is for the sake of readability.

I use utcNow as my staring point, but any date/time should work if formatted as yyyy-MM-dd.

My expresssions are in the comments at the top of each action.

 

NextMonth1.jpgNextMonth2.jpg

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

5 REPLIES 5
Highlighted
Super User III
Super User III

Re: Issue with AddToTime

@silkwire 

This shouldn't be hard.......

Please see my screen shots below.  I could have combined all of my variables into one really ugly nested expression but I left as is for the sake of readability.

I use utcNow as my staring point, but any date/time should work if formatted as yyyy-MM-dd.

My expresssions are in the comments at the top of each action.

 

NextMonth1.jpgNextMonth2.jpg

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

View solution in original post

Highlighted
Helper I
Helper I

Re: Issue with AddToTime

I appreciate your help. It doesn't quiiite do the trick though. What about if next month is in next year?

 

I just wish addToTime worked like DateAdd in PowerApps 😕 much more useful.

Highlighted
Helper I
Helper I

Re: Issue with AddToTime

addToTime(utcnow(), 4, 'Week') will add four weeks.

 

addToTime(utcnow(), 1, 'Month') should jump to the next month, not just be a different way of saying add four weeks.

Highlighted
Super User III
Super User III

Re: Issue with AddToTime

@silkwire :

 

I agree - I missed the end of year issue with month.  That said, that can be fixed with a simple if expression.

 

I also agree that this should be simple.......

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott
Highlighted
Helper I
Helper I

Re: Issue with AddToTime

Thanks for the help! I will mark your first response as the solution.

 

I ended up solving in PowerApps itself by creating a manual collection and building future dates with DateAdd() with an additional counter column that my If statement checks against to see if it should Patch the new row. 

Helpful resources

Announcements
firstImage

Super User Program Update

Three Super User rank tiers have been launched!

firstImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

Top Solution Authors
Users online (9,174)