You are currently viewing How Power Automate exclude weekends and holidays between dates? correct solution
Power Automate calculate working days between dates

How Power Automate exclude weekends and holidays between dates? correct solution

In this blog post, we will learn how power automate exclude weekends and holidays from date. to understand how power automate calculate working days between dates

Power Automate exclude weekends and holidays

  • Use Case:
    • In the approval flow in Power Automate we want to know how many business days did any approver take to make a decision from the time they receive the request in their inbox till they approve or reject the Approval Request.
      Business time is assumed to be Monday to Friday 9:00am to 5:00pm, so weekends and public Holidays are not counted. For example, if Approval is sent to CEO on a Friday, the deadline would be on Tuesday (not Sunday).
    • Holidays is a SharePoint list

Step1: Get Holidays between the two dates

Get the list of holidays between the two dates, form the time when the Approval Created that will represent Date1 , and Date2 when the Approver Approve/Reject the request, we can represent it with utcNow() to get the current date when we receive the outcome of the approval”.

Power Automate exclude weekends and holidays
Power Automate exclude weekends and holidays

Step2: Calculate the number of weekends that included in this interval

We will calculate how many week ends included from the time the flow sent the Approval request till the time when the approver approved or rejected.

We will use the dayOfWeek function to check if the day is a week end or not, in this scenario we suppose that the week end is Saturday and Sunday : the dayOfWeek function will return 0- Sunday 6- Saturday.

We have to loop for each day from the start of the approval till the approver take action to approve or reject to find if it is a week end or not , If the day is a week end then I will increment the number of weekends.

power automate exclude weekends
Exclude week ends between the two dates

Step3: Exclude the holiday if it is week end

Also we have to check if the holidays is a week end in order not to count the day twice one in holidays and one as week end if it is a week end.

Exclude the holiday if it is week end
Exclude the holiday if it is week end

Step4: Calculate the no of business days exclude weekends and holidays

Now we will subtract the number of weekends and holidays exclude week ends from the number of days between the two date to calculate how many business days the approver take to approve or reject excluding the holidays and week ends.

Power Automate exclude weekends and holidays
Power Automate exclude weekends and holidays
power automate calculate working days between dates

This is how power automate calculate working days between dates

See Also
Join us
Need Help
  • Have a related question? Please ask it at deBUG.to Community.

Heba Kamal

Microsoft MVP, MCT, Technical Speaker, Blogger, and Microsoft 365 and Power Platform Consultant.