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
No.1 you need to convert UTCNow to your local time
Then Split By Space using Compose Data Operation to Get Time Part only:
Then Add Another Compose Data Operation to Split the Hours From Minutes:
Then add a condition as below:
Condition 1: Expression:
Condition 2: Expression:
To check if it is Friday
You can use the Day of Week Function as below
Then another condition to check if day of week = Friday which is equal to 5
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.
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.
P.S. take a look at my new blog here
Check out the News & Announcements to learn more.
Participate in the Power Virtual Agents Community Challenge
Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.
DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.