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
- 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.
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”.
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.
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.
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.
This is how power automate calculate working days between dates
See Also
- How To Format Date In Power Automate?
- Power Automate Add Days To Date
- How PowerApps Submit Multiple Forms To SharePoint List?
- How PowerApps Add Business Days To Date Excludes Weekends And Holidays?
- Nested Collection In PowerApps :3 Level
- How To Use PowerApps DateDiff Function?
- PowerApps Parse JSON Example
- How To Use Switch Function In PowerApps?
- PowerApps Lookup Function Examples : Complete Tutorial
Join us
- Subscribe to Power Platform Geeks.
- Register to Saudi Arabia Power Platform User Group.
Need Help
- Have a related question? Please ask it at deBUG.to Community.