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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Users online (3,969)