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
MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

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

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

Top Solution Authors
Users online (34,103)