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
Community Champion
Community Champion

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
MPA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.

Users online (1,303)