Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Triggers
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
  • Get help with flow
Menu

Schedule Power Automate flow to run only last Friday of the month

Posted on April 10, 2022April 10, 2022 by Tom

“I’d like to send a reminder on the last Friday in each month, how can I schedule it in Power Automate given various month length?”


When scheduling recurrent flows for a specific day in a month, it can go two ways. You can get the day from the beginning of a month, e.g. first or second Tuesday in a month, or you can take it from the end. While taking it from the beginning is very straightforward, from the end it’s a bit more complicated due to the different length of each month. The day must be always within the last 7 days of the month, but how do you get it if a month can have between 28 and 31 days?

Get the last day of the month

Since each month can have a different number of days, the first step is to get the number for the current month. Unfortunately, Power Automate doesn’t have any expression that would give you the end of a month, but it has an expression to give you the start of a month. Using the startOfMonth(…) expression you’ll get start of the current month, no matter what day it is today.

startOfMonth(utcNow())

But that’s the start of this month and you need the end of this month, which is exactly 1 month – 1 day away from the start. Add a month to that date, and remove 1 day with addToTime(…) and addDays(…) expressions. Using the ‘dd’ format you’ll get only the number for the last day in the current month.

addDays(addToTime(startOfMonth(utcNow()),1,'Month'),-1,'dd')
Power Automate schedule last of the month

Check if today’s date is in the last 7 days

Now, when you’ve got the last date in the month, you can use it in a trigger condition. If it’s the last Friday (or any other day) in the month, it must be in the last 7 days. That means you’ll need borders, the day must be between the last day of the month and the last day of the month -6 days.

Use the expression above as one of the borders, the last day of the month. The other expression would then be very similar, subtracting 7 days instead of 1.

addDays(addToTime(startOfMonth(utcNow()),1,'Month'),-7,'dd')

Convert the number into an integer with the int(…) expression, and check if today’s date fits in between: last day of the month -6 <= today <= last day of the month.

@and(
lessOrEquals(int(utcNow('dd')),int(addDays(addToTime(startOfMonth(utcNow()),1,'Month'),-1,'dd'))),
greaterOrEquals(int(utcNow('dd')),int(addDays(addToTime(startOfMonth(utcNow()),1,'Month'),-7,'dd')))
)

You can then use it as a trigger condition in the recurrence trigger.

Such trigger condition will guarantee that the flow will run only if it’s the last week in the month. Combine it with the specific day and you’re done.

Summary

It’s a bit more complicated to schedule a Power Automate flow to run on the last specific day of the month than scheduling it from the beginning. Before you start comparing the dates you must get the dates for the last 7 days in each month, but from then on it’s the same approach. Select which day it should be, and check if the date fits in the range of the last 7 days.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

1 thought on “Schedule Power Automate flow to run only last Friday of the month”

  1. a says:
    May 26, 2022 at 2:52 am

    good post. thank you!

    Reply

Leave a Reply Cancel reply

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

Do you know what to do, but not how to do it?

Get The Ultimate Power Automate expressions cheat sheet and translate your thoughts into flows with ease!


NEW! Master the HTTP requests to SharePoint with a new cheat sheet!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Use Power Automate to forward Outlook events upon registrationJanuary 29, 2023
  • Why the condition is false for the same numbers (Power Automate)January 25, 2023
  • How to forward event invitation to other calendar (Power Automate)January 22, 2023
  • Run ‘For selected item’ flow from non-default environment (Power Automate)January 18, 2023
  • Hide button in SharePoint list after Power Automate flow startedJanuary 15, 2023

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2023 Let's POWER Automate | Theme by SuperbThemes