In this blog post, we will learn how Power Automate add working days to date, or how Power Automate add business days to date.
Power Automate add working days to date
The DateDiff function allows an app to calculate the difference between two dates , but what if your organization only needs to consider the business days excluding weekends and holidays, this what we will learn here to add business days using power automate. To check how to add business days power Apps please check this article
To add working days to a date this mean to exclude Weekends and Holidays from these days.
- Give any approver a deadline of 2 business days “Working days” to make a decision from the time they receive the request in their inbox.
- 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).
Steps :Power Automate add business days to date
- Remove holidays from the period, here we store the holidays in a SharePoint list with 2 fields holiday name and its start date.
- Remove Weekends from the period
There is no one formula for holidays, each country has its own list of holidays.
- Get the list of holidays that are greater than or equal your date “here is the modified date of the SharePoint list” and less than or equal the date that is 2 days after your date (Modified+2) to check if there are any holidays in this period after adding 2 days, here I used addDays function to add 2 days to the modified date.
- Next we add the number of days that will be holiday to your date and add the 2 business date that we want to add as a dead line. ere use the function length to get the number of holidays that will be found in this period.
- Next we have to exclude the weekends from the calculation to calculate the Deadline correctly excluding Weekends and holidays.
- save your date “Modified” in variable that is StartApprovalDate here.
- Use “Do until” to loop until your variable is greater than the Deadline that we calculated before and chick if every day in this period is Weekends or not Note: weekends here are Saturday and Sunday : the dayOfWeek function will return 0 for Sunday 6 for Saturday.
- If the day is a Weekend then we will add one day to the variable start date to be the next day and increment the number of weekends “that is variable that initialized with zero before”.
- If the day is not a weekend then add day to the variable only to move to the next day.
- this will loop through the period till dead line
- Next we will add the number of weekends that we will found to the deadline that we calculated before. So the new deadline is after adding 2 business days to the date and ignoring weekends and holidays.
This the whole steps that we defined before
This is how power automate add working days to a date
- How Power Automate Exclude Weekends And Holidays Between Dates?
- 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
- Subscribe to Power Platform Geeks.
- Register to Saudi Arabia Power Platform User Group.
- Have a related question? Please ask it at deBUG.to Community.