On the Power Automate community site I found an interesting question about finding the first working day of the month using Microsoft Power Automate
So I thought I’ll take that challenge!
First of all I need a date. (No not that kind of date!).
As this is a test flow I’m using a manual start of the flow to collect any date from the user starting the flow.
This will give me the DateInMonth as shown below. in the format of 2013-01-18. Then I’ll replace the day with 01 and I’ve got the first day of the month.
Easy, just a bit of text cutting and replacing and we’re done.
The following expression does the trick:
concat(substring(variables(‘MyDate’),0,8), ’01’)

Then we need to check if this day is a holiday. I took the 2013-01-18 date here so that I’ve got a holiday being returned for the first of the month.
I found a web service that can give me the UK bankholidays at
http://www.work-day.co.uk/api_documentation.php
So now I can check with a simple condition of the first day of the month is a holiday or not.
The condition will simply look like this:
@greater(indexOf(body(‘HTTP’), variables(‘FirstDay’)), 0)
Ok. This is easy but we haven’t got the weekends covered yet.
This is where flow has an answer out of the box. With the following expression using the dayOfWeek function your done in no time:
@equals(dayOfWeek(variables(‘FirstDay’)), 0)
Now all we need to do is increment the 1st day of the month to the 2nd day of the month and rerun our tests until we have found working day.

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

3 thoughts on “Get the first working day of the month in Power Automate”

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading