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.
Solved! Go to Solution.
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.
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.
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.
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.
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.......
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.
…
….
User | Count |
---|---|
16 | |
16 | |
14 | |
9 | |
8 |
User | Count |
---|---|
27 | |
26 | |
24 | |
23 | |
14 |