I am currently creating a flow that is triggered from a form submission for payroll adjustments.
All adjustments need to be made by the 16th of each month. I am trying to figure out what expression I need to set the planner task due date to the next closest 16th of the month.
I'm unsure if and or how to do this.
Thanks in advance.
Solved! Go to Solution.
Hi again!
So, let's assume you add a 'initialize variable', name 'currentDateTime' type string, and assign as its value the expression
utcNow()
You can get current monthday by means of the following expression
dayOfMonth(variables('currentDateTime'))
Now, what shall we do if we need to set Due Date as 16th current month?
addDays(startOfMonth(variables('currentDateTime')),15)
And, what shall we do if we need to set Due Date as 16th next month?
addDays(addToTime(startOfMonth(variables('currentDateTime')),1,'Month'),15)
Finally, the requested calculation: is 16th current month ok? or shall we set 16th next month?
if(less(dayOfMonth(variables('currentDateTime')),16),addDays(startOfMonth(variables('currentDateTime')),15),addDays(addToTime(startOfMonth(variables('currentDateTime')),1,'Month'),15))
Hope this helps
Proud to be a Flownaut!
Hi!
"All adjustments need to be made by the 16th of each month. I am trying to figure out what expression I need to set the planner task due date to the next closest 16th of the month."
So, if your form submission is received the 16th or later, you need to set Due Date to the 16th, next month, right?
And if your form submission is received from 1st to 15th, you need to set Due Date to the 16th, current month, right?
Also, the date to start calculating from, is the date the form is submitted? Or a date provided as an answer to one of the questions in the survey?
Thanx!
Proud to be a Flownaut!
You can use a combination of utcNow, dayOfMonth, formatDateTime, getFutureTime, and, if your timezone is not utcNow, convertFromUtc.
This way you can:
More info about the expressions with date time: https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#d...
Hopfully this helps!
Cheers,
Daniel
Proud to be a Flownaut!
Yes all those statements are correct. Would you know how to formulate that expression? I'm a business analyst so not overly fluent in expression coding.
Cheers
Hi again!
So, let's assume you add a 'initialize variable', name 'currentDateTime' type string, and assign as its value the expression
utcNow()
You can get current monthday by means of the following expression
dayOfMonth(variables('currentDateTime'))
Now, what shall we do if we need to set Due Date as 16th current month?
addDays(startOfMonth(variables('currentDateTime')),15)
And, what shall we do if we need to set Due Date as 16th next month?
addDays(addToTime(startOfMonth(variables('currentDateTime')),1,'Month'),15)
Finally, the requested calculation: is 16th current month ok? or shall we set 16th next month?
if(less(dayOfMonth(variables('currentDateTime')),16),addDays(startOfMonth(variables('currentDateTime')),15),addDays(addToTime(startOfMonth(variables('currentDateTime')),1,'Month'),15))
Hope this helps
Proud to be a Flownaut!
Thank you so much for your help! This is exactly what I was after and I learnt something new 🙂
Thanks for detailing how you got there rather than just giving the answer, it was very helpful.
Cheers
The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.
Announcing a new way to share your feedback with the Power Automate Team.
Learn to digitize and optimize business processes and connect all your applications to share data in real time.
User | Count |
---|---|
64 | |
23 | |
16 | |
15 | |
11 |
User | Count |
---|---|
121 | |
36 | |
32 | |
28 | |
26 |