cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Dowre
Regular Visitor

Excluding weekends in my "booking system" using addDays

Hello,

 

I have a booking system which gives a patient dates to visit a clinic. How it works, we pick "start day" a to that date I am adding days using this "addDays(triggerBody()?['...here is start date...'],7)", and it creates a "visit" in calendar, after that there is another action same like that before but with different number, like that "

addDays(triggerBody()?['Datum_x0020_randomizace_x003a_'],)14" and more... 
 
What I need... I need to exclude weekends and I really dont know how... If someone know how, I would be greatful for your help. 🙂 
1 ACCEPTED SOLUTION

Accepted Solutions
v-yamao-msft
Community Support
Community Support

Hi @Dowre,

 

It seems that you would like to create an event only on workday.

Please check the following flow for a reference.

Trigger the flow by a button. Select a Text input and a Date input.

Add the action Create event. Input the following code in the Start time and End time field:

 

if(equals(dayOfWeek(addDays(triggerBody()['date'],7)),6),addDays(triggerBody()['date'],9), if(equals(dayOfWeek(addDays(triggerBody()['date'],7)),0),addDays(triggerBody()['date'],8),addDays(triggerBody()['date'],7)))

 

Above function will check if the day of week is equal to 6 or 0, if yes, add corresponding dates on the initial date, if no, use the initial date as the start or end date.

1.PNG2.PNG

Please check it for a reference and try it on your side.

Reference doc on dayofWeek function:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#d...

 

Best regards,

Mabel

 

Community Support Team _ Mabel Mao
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

3 REPLIES 3
v-yamao-msft
Community Support
Community Support

Hi @Dowre,

 

It seems that you would like to create an event only on workday.

Please check the following flow for a reference.

Trigger the flow by a button. Select a Text input and a Date input.

Add the action Create event. Input the following code in the Start time and End time field:

 

if(equals(dayOfWeek(addDays(triggerBody()['date'],7)),6),addDays(triggerBody()['date'],9), if(equals(dayOfWeek(addDays(triggerBody()['date'],7)),0),addDays(triggerBody()['date'],8),addDays(triggerBody()['date'],7)))

 

Above function will check if the day of week is equal to 6 or 0, if yes, add corresponding dates on the initial date, if no, use the initial date as the start or end date.

1.PNG2.PNG

Please check it for a reference and try it on your side.

Reference doc on dayofWeek function:

https://docs.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference#d...

 

Best regards,

Mabel

 

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

Hi @v-yamao-msft!

 

Thank you for your solution, I tried to implement it to my flow and it works great!

I would like to use your Idea but adding a number of days but I did not get this to work Could you please help me out with this 

 

Thanks in advanced @v-yamao-msft 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (2,985)