Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Using Flows
Unanswered

calculate business days in workflow, exclude weekends and holidays

(0) ShareShare
ReportReport
Posted on by 3

Hi!

 

I'm creating a workflow of reminders but I'm kinda stuck at the moment. 

 

I have created this list:

listSP.png

 

and until now I'm testing by triggering the workflow manually but it's going to be a scheduled workflow. The workflow consists of sending a reminder 3 days in advance, 1 day in advance and on the same day as the date entered in the field (Compliance date and / or report). Until there, everything is fine!:

listSP.png

What has been difficult for me is how to calculate what the working days are, in this case Monday through Friday. I need to exclude Saturdays, Sundays and holidays.

 

¿What should i do to make it work?

Could you please help me! and I really appreciate it.

  • IsaacM22 Profile Picture
    3 on at
    Re: calculate business days in workflow, exclude weekends and holidays

    Thank you very much for your answer.

    Until now I have had no success to exclude weekends at least.

     

    I've done this:

     

    SP.png

     

    In the "compose" block, I have this expression:  

    dayOfWeek(utcNow()) and returns the day of the week. in the condition valid that.
     
    the flow begins by sending a reminder email, for example. (An email must be sent 4 days in advance) then, if the date is for ("09-01-2020" Tuesday). then the reminder email should be sent today ("08-26-2020" Wednesday). Counting business days (Thursday, Friday, Monday and Tuesday). I can't validate that, it doesn't exclude Saturday and Sunday and by not excluding the weekend, the mail is sent for Sunday, which cannot be the case.
     
  • haroldk Profile Picture
    on at
    Re: calculate business days in workflow, exclude weekends and holidays

    I have worked on a flow that will calculate the end date given the start date and the number of working days. This formula will exclude weekends. You might be able to use this to get the working days. Another option would be to use an unattended UI Flow and run a calculation in Excel to return the number of working days.

    https://docs.microsoft.com/en-us/power-automate/ui-flows/overview

     

    haroldbk_msft_0-1598305681715.png

    This is the expression in Compose 2 - Compose 3 outputs the end date.

     

     

    if(equals(dayOfWeek(adddays(if(equals(dayOfWeek(variables('startdate')),6),addDays(variables('startdate'),2), if(equals(dayOfWeek(variables('startdate')),0), adddays(variables('startdate'),1),variables('startdate'))), add(mul(7,div(variables('duration'),5)), mod(variables('duration'),5)))),6), addDays(adddays(if(equals(dayOfWeek(variables('startdate')),6), addDays(variables('startdate'),2), if(equals(dayOfWeek(variables('startdate')),0), adddays(variables('startdate'),1),variables('startdate'))), add(mul(7,div(variables('duration'),5)), mod(variables('duration'),5))),2), if(equals(dayOfWeek(adddays(if(equals(dayOfWeek(variables('startdate')),6), addDays(variables('startdate'),2), if(equals(dayOfWeek(variables('startdate')),0), adddays(variables('startdate'),1),variables('startdate'))), add(mul(7,div(variables('duration'),5)), mod(variables('duration'),5)))),0), adddays(adddays(if(equals(dayOfWeek(variables('startdate')),6), addDays(variables('startdate'),2), if(equals(dayOfWeek(variables('startdate')),0), adddays(variables('startdate'),1),variables('startdate'))), add(mul(7,div(variables('duration'),5)), mod(variables('duration'),5))),1), adddays(if(equals(dayOfWeek(variables('startdate')),6), addDays(variables('startdate'),2), if(equals(dayOfWeek(variables('startdate')),0), adddays(variables('startdate'),1),variables('startdate'))), add(mul(7,div(variables('duration'),5)), mod(variables('duration'),5)))))

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,601 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,942 Most Valuable Professional

Leaderboard

Featured topics

Restore a deleted flow