cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Setting Planner task due date to the next upcoming XX day of the month

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Dual Super User III
Dual Super User III

Re: Setting Planner task due date to the next upcoming XX day of the month

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

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

5 REPLIES 5
Highlighted
Dual Super User III
Dual Super User III

Re: Setting Planner task due date to the next upcoming XX day of the month

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!

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



Highlighted

Re: Setting Planner task due date to the next upcoming XX day of the month

@James_Anderson 

 

You can use a combination of utcNow, dayOfMonth, formatDateTime, getFutureTime, and, if your timezone is not utcNow, convertFromUtc.

 

This way you can:

  • get the current time - utcNow
  • change it to your timezone if needed - convertFromUtc
  • get the day of month - dayOfMonth
  • if > 16 you need to set the due date to the next month - getFutureTime
  • and maybe you need formatDateTime to get a different date time format

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







Did I answer your question? Mark my post as a solution!


Proud to be a Flownaut!






Highlighted
Frequent Visitor

Re: Setting Planner task due date to the next upcoming XX day of the month

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

Highlighted
Dual Super User III
Dual Super User III

Re: Setting Planner task due date to the next upcoming XX day of the month

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

 



Each time you click on any of our inspiring answers 'Thumb up' icon...
...an ewok scapes from the stormtroopers.

Be grateful, Thumbs up! Save the Galaxy for free!


Escribo sobre Power Automate en:
https://medium.com/anyone-can-automate/

Proud to be a Flownaut!



View solution in original post

Highlighted
Frequent Visitor

Re: Setting Planner task due date to the next upcoming XX day of the month

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

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
Top Kudoed Authors
Users online (8,366)