First and last workday of the month in Power Automate

Here we go again. The last workday of the month.

Most of us have reoccurring things we need to do on the last workday of the month. Approve a report, make sure our time sheets are submitted, that all invoices are sent and so on. Similar with the first workday of the month.

If we’re lucky we can use Power Automate to do these things for us so we can lean back and don’t have to think about them. If that dream scenario is our of reach we can at least get Power Automate to send as a reminder, add a task, book some time in our calendars or similar that at least remind us about the things we need to do and when we need to take care of these things.

There’s unfortunately no current and built-in function in Power Automate or Power Apps we can use to simply get the first or last workday of the month. But we can still accomplish this by combining some of the built-in functions that are there. The principal is that we run a Flow every day and look at today’s date to see if today is the last or first workday of the month.

First workday of the month

To get the first workday of the month we first have to identify the first of the month by using the following expression.

startOfMonth(utcNow())

Once we know the first day of the month, we’re able to look at the day of the week of this date to determine if we need to add one or two days if the first occur on a weekend. The dayOfWeek will tell us the weekday of the week with 1 being Sunday and 6 Saturday.

if (equals(dayOfWeek(variables('FirstDayMonth')),0),addToTime(variables('FirstDayMonth'),1,'day'),if (equals(dayOfWeek(variables('FirstDayMonth')),6),addToTime(variables('FirstDayMonth'),2,'day'),variables('FirstDayMonth')))

Last workday of the month

To get the last workday of the month we first have to identify the last date of the current month by using the following expression. We basically use the current date, add one month to it, then the first of that month to finally subtract one day.

subtractFromTime(startOfMonth(addToTime(utcNow(),1,'month')),1,'day')

With the last date of the month we’re able to subtract one or two days from that if the last date happens on a weekend. We use the dayOfWeek function to determine if the last date of the month happens on a Sunday (dayOfWeek 1) or Saturday (dayOfWeek 6).

if (equals(dayOfWeek(variables('LastDayMonth')),0),subtractFromTime(variables('LastDayMonth'),2,'day'),if (equals(dayOfWeek(variables('LastDayMonth')),6),subtractFromTime(variables('LastDayMonth'),1,'day'),variables('LastDayMonth')))

Complete Flow

Below you see the complete picture of this Flow. You can also download the Flow here.

Please note that the expressions in this article doesn’t consider any bank holidays or similar that may affect the days we work every month.