How to Check if a Date is on a Business Day in Power Automate

Do you need to test if a date is a business day in your flow?

Power Automate is a business tool for automating processes. As such it’s likely any deadlines, task assignments, and operational schedule dates will need to be business days.

You can test if your dates fall on a business day with a simple function in Power Automate.

This article will show you how to check if a date is a business day using the dayOfWeek function and a Condition action.

DayOfWeek Function Syntax

To check if a date is on a business day in Power Automate, you can use the dayOfWeek function.

dayOfWeek(<date>)

This function returns an integer number representing the day of the week.

  • <date> is the date and timestamp for which you want to return the weekday number.

This function will return the following values.

  • 0 if the date is a Sunday
  • 1 if the date is a Monday
  • 2 if the date is a Tuesday
  • 3 if the date is a Wednesday
  • 4 if the date is a Thursday
  • 5 if the date is a Friday
  • 6 if the date is a Saturday

If you want to know if a given date is on a business day or not, you can compare the result of the dayOfWeek function to the desired range of business days. Typically, business days are Mondays to Fridays, which corresponds to integers 1 to 5.

If the condition is true, then the date is a business day. Otherwise, it’s a weekend.

Use Condition to Test dayOfWeek Function Results

This section will explore how to set up a Condition action to determine if the date is a business day and will suppose the dayOfWeek function has already been called with your date.

In this example, the date to test is inside a Compose action, and the expression dayOfWeek(outputs('Compose')) calculates the day of the week for this date.

This result is then referenced in the Condition action as outputs('dayOfWeek').

Condition Function to Test dayOfWeek Results

The dayOfWeek function returns 0 for Sunday and 6 for Saturday. This means to test if the date is not a business day and instead falls on the weekend, you only have to test if the value is 0 or 6.

  1. Add the Condition action to your flow.
  2. Click the Add button and select Add row in the Condition action to allow 2 conditions. One will test fo a 0 and the other for a 6.
  3. Select the Or option for the conditions. This means the If yes branch will run if either of the conditions are true.
  4. Place the dynamic content for dayOfWeek results on the left side of condition 1, select the is equal to option for the condition, then enter 6 on the right side.
  5. Place the dynamic content for dayOfWeek results on the left side of condition 2, select the is equal to option for the condition, then enter 0 on the right side.
  6. Place any actions you wish to execute if the date is found to be a business day in the If no branch of the condition.

The If no branch will run whenever the date is a business day..

Conclusions

Checking if a date falls on a business day can be achieved using built-in functions and actions.

By using the dayOfWeek function, you can determine the day of the week for a given date and test if this is a weekend or not.

This will return a numerical value from 0 (Sunday) to 6 (Saturday) representing the day of the week. With this information, you can ascertain whether the date is a business day or not.

Then you can create a condition that checks if the value is either 0 or 6, which corresponds to a weekend.

Have you needed to test your dates if they fall on a business day? Let me know in the comments!

About the Author

John MacDougall

John MacDougall

John is a Microsoft MVP and freelance consultant and trainer specializing in Excel, Power BI, Power Automate, Power Apps and SharePoint. You can find other interesting articles from John on his blog or YouTube channel.

Related Articles

Comments

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Get the Latest Tech Tips

Write For Us

Are you a tech enthusiast with a talent for writing great content? Come write for us!

Follow Us

Follow us on social media to stay up to date with the latest in tech!