cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
vlr516
Helper I
Helper I

How to Write Expression for Get Calendars Based on the Day of the Week

I am using the template, Email me with a list of upcoming Calendar events, connecting to an Outlook calendar. 

vlr516_0-1613673868468.png

 

I'd like the flow to trigger on weekdays to look at my calendar events for the next calendar date, with the exception on Friday to jump forward to Monday's calendar events. I do not know how to create the expression for the Friday email to look forward by additional hours than the flow does for all the other days. 

 

Here is what I have which I know works:

 

  1. Here is my setup of the trigger event.

image006.jpg

 

2. I set the PullStartTime variable to a dynamic expression:

convertTimeZone(startOfDay(addDays(utcNow(),1),'hh:mm tt dd MMM, yyyy'),variables('UserTimeZone'),'UTC')

 

3. Then I go get my calendar and I'm using the PullStartTime as my start time to get calendar view of events (v2) and end time is a dynamic expression:

addHours(variables('PullStartTime'),24)

thumbnail (3).jpeg

 

This works for the triggers on Monday through Thursday. Somehow I need to change the expression to be an if statement but I'm not sure exactly how to write it. Below is my thought for the End Time but I keep getting errors.

 

if(equals(dayOfWeek), 'Friday'), addHours(variables('PullStartTime'),48), addHours(variables('PullStartTime'),24))

 

Any help would be appreciated. 

 

Thanks. 

 

 

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
v-yiwenxie-msft
Microsoft
Microsoft

Hi @vlr516 

 

The expression you want to put in your 'End Time' is wrong, you can try this:

if(equals(dayOfWeek(variables('PullStartTime')),5),addHours(variables('PullStartTime'),48),addHours(variables('PullStartTime'),24))
 

Best Regards,
Community Support Team _ Kira Xie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yiwenxie-msft
Microsoft
Microsoft

Hi @vlr516 

 

The expression you want to put in your 'End Time' is wrong, you can try this:

if(equals(dayOfWeek(variables('PullStartTime')),5),addHours(variables('PullStartTime'),48),addHours(variables('PullStartTime'),24))
 

Best Regards,
Community Support Team _ Kira Xie
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you. That worked. 

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Community Calls Conversations

Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (5,610)