cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

Calculate Due date

I am facing problem in power automate, my task is generating due due, for ex: If I got the the mail for the task before 5 pm, task due date generate for the same day , if mail received after 5 pm due date generate for the next day and if mail received on Friday after 5pm, due date generate for the Monday

3 REPLIES 3
Mira_Ghaly
Dual Super User II
Dual Super User II

@Anonymous 

No.1 you need to convert UTCNow to your local time

 

Mira_Ghaly_0-1614585637567.png

Then Split By Space using Compose Data Operation to Get Time Part only:

Mira_Ghaly_1-1614585969961.png

 

Expression:

split(body('Convert_time_zone'),' ')

 

Then Add Another Compose Data Operation to Split the Hours From Minutes:

 

Mira_Ghaly_3-1614586147392.png

Expression:

Split(outputs('Compose')[1],':')

Then add a condition as below:

Mira_Ghaly_5-1614586473906.png

 

Condition 1: Expression:

int(outputs('Compose_2')[0])

Condition 2: Expression:

outputs('Compose')[2]

 

 

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
Mira_Ghaly
Dual Super User II
Dual Super User II

@Anonymous 

To check if it is Friday

 

You can use the Day of Week Function as below

Mira_Ghaly_0-1614586757738.png

 

Expression:

dayOfWeek(body('Convert_time_zone'))

Then another condition to check if day of week = Friday which is equal to 5

Mira_Ghaly_1-1614586995169.png

 

If this post helps you with your problem, please mark your as Accepted solution.If you like my response, please give it a Thumbs Up.

Blog: here
DamoBird365
Super User
Super User

Morning @Anonymous 

 

I would use a switch step for those three scenarios.

 

DateTime lessorequals 17:00 -> set to today

DateTime greater 17:00 AND DAY notequal 'FRIDAY' -> set to next day

DateTime greater 17:00 and DAY equal 'Friday' -> set to Monday (anything else - so you don't need an expression)

 

You could use the compose step to format your datetime as a day and a time (i've used utcnow() in my example but update this to your variable name)

You'll need the epression:

formatDateTime(utcNow(), 'dddd') to convert a datetime to day of week

formatDateTime(utcNow(), 'HH:mm') to convert a datetime to time

 

A third compose to run the logical expression and use the outcome from this in your switch.

 

Untitled.png

 

The expression I tested for the 3rd compose is 

if(lessOrEquals(outputs('Time'),'17:00'),'Option1', if(and(greater(outputs('Time'),'17:00'), Not(equals(outputs('Day'),'Friday'))), 'Option2', 'Option3'))

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Cheers,
Damien


P.S. take a look at my new blog here

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Users online (1,111)