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

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

@amansharma_751 

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

@amansharma_751 

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 @amansharma_751 

 

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
Process Advisor

Introducing Process Advisor

Check out the new Process Advisor community forum board!

MPA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

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.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Users online (2,284)