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

@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

@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

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

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

@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

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
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Users online (10,788)