I have End date, and Extended date. Right now, I want to calculate Final Date.
If I have End date, I need to add a month to the date. If End date is empty, then I have to add a month to Extended date to get the final date. How do I do the flow?
In the set variable of the Final Date field you could use if and empty functions in a expression to achieve this.
Below is an example:
if(empty(variables('EndDate')), addDays(variables('ExtendedDate'),30), addDays(variables('EndDate'),30))
If the end date is on the 5th you want the final date value to also be on the 5th the next month? Regardless if the month has less (working) days or even if it's a leap year?
If that's the case you should be able to use the addToTime function instead. Use this expression instead:
if(empty(variables('EndDate')), addToTime(variables('ExtendedDate'),1,'Month'), addToTime(variables('EndDate'),1,'Month'))
hi @Expiscornovus ,
thanks for the feedback. so addtoTime doesn't count the leap year is it? If I want to include leap year,there must be a calculation right?
No that shouldn't be needed. The addToTime should also handle leap years. I have tested it with 12th of February 2020 and the Final Date is set as the 12th of March 2020.
Hi @Expiscornovus, I've tried it,and it works perfectly for creating new data. However, when I try to trigger existing record using the addtoTime, it doesn't give the correct result:
It's not entirely clear what you are doing in your flow from the screenshots.
But I am assuming that you are looping through a set of end dates? If that's the case my guess would be that you also need to put that set variable 3 action within the first apply to each loop which contains the set variable action.
If the set variable 3 action is outside of the loop it will probably be only applied to your last date of record 69.
I hope that makes sense?
Learn how to create your own user groups today!
Check out the new Power Platform Community Connections gallery!
Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.