cancel
Showing results for
Did you mean:

## Configure Flow to Only Run on the Last Monday of the Month

Hi,

I am looking to add a condition to one of my existing flows to only run if an email arrives on the last Monday of the month.  This should look at the date in the Eastern time zone, if that helps.  As I mentioned, I already have a flow to create my attachments in SharePoint, so that part is done.

Any assistance is greatly appreciated!

3 REPLIES 3

Anybody have any ideas?

Community Support

Hi @ScottR-MT,

I can't think of a suitable Expression here to directly determine whether the current mail receiving date is the last Monday of this month.

However, consider using a combination of Condition and Expression to determine if the current date is the expected one, and if so, execute the following action.

• First determine if Received Time is Monday, and if so, perform the following judgment.
• Then use ticks() function to convert the last day of the month and Received Time into numbers, and you can see what ticks() function does.
• Use div() function to get the difference between the two dates, divide by 864000000000, and get a difference of a few days between the two dates.
• If the difference is less than or equals to 7, then Received Time of this message is the last Monday of the month.

Expression：

Condition:

`dayOfWeek(triggerBody()?['DateTimeReceived'])`

lastDay:

`ticks(formatDateTime(adddays(concat(add(int(formatDateTime(utcNow(), 'yyyy')),if(equals(formatDateTime(utcNow(), 'MM'), '12'), 1, 0) ),'-',add(int(formatDateTime(utcNow(), 'MM')),if(equals(formatDateTime(utcNow(), 'MM'), '12'), -11, 1) ),'-01T08:00Z'),-1),'yyyy-MM-ddTHH:mm'))`

`ticks(triggerBody()?['DateTimeReceived'])`

dayDiff:

`div(sub(outputs('lastDay'),outputs('ReceivedTime')),864000000000)`

Condition 2:

`div(sub(outputs('lastDay'),outputs('ReceivedTime')),864000000000)`

Image reference:

You could consider testing this Flow on Monday.

Best Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Community Support

Hi @ScottR-MT ,

Regards,

Community Support Team _ Barry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Announcements

#### Back to Basics Tuesday Tip #9: All About the Galleries

This is the ninth post in our series dedicated to helping the amazing members of our community--both new members and seasoned veterans--learn and grow in how to best engage in the community! Each Tuesday, we feature new content that will help you best understand the community--from ranking and badges to profile avatars, from Super Users to blogging in the community. Our hope is that this information will help each of our community members grow in their experience with Power Platform, with the community, and with each other!     Today's Tip: All About the Galleries Have you checked out the library of content in our galleries? Whether you're looking for the latest info on an upcoming event, a helpful webinar, or tips and tricks from some of our most experienced community members, our galleries are full of the latest and greatest video content for the Power Platform communities.   There are several different galleries in each community, but we recommend checking these out first:   Community Connections & How-To Videos Hosted by members of the Power Platform Community Engagement  Team and featuring community members from around the world, these helpful videos are a great way to "kick the tires" of Power Platform and find out more about your fellow community members! Check them out in Power Apps, Power Automate, Power Pages, and Copilot Studio!         Webinars & Video Gallery Each community has its own unique webinars and videos highlighting some of the great work being done across the Power Platform. Watch tutorials and demos by Microsoft staff, partners, and community gurus! Check them out: Power Apps Webinars & Video Gallery Power Automate Webinars & Video Gallery Power Pages Webinars & Video Gallery Copilot Studio Webinars & Video Gallery   Events Whether it's the excitement of the Microsoft Power Platform Conference, a local event near you, or one of the many other in-person and virtual connection opportunities around the world, this is the place to find out more about all the Power Platform-centered events. Power Apps Events Power Automate Events Power Pages Events Copilot Studio Events   Unique Galleries to Each Community Because each area of Power Platform has its own unique features and benefits, there are areas of the galleries dedicated specifically to videos about that product. Whether it's Power Apps samples from the community or the Power Automate Cookbook highlighting unique flows, the Bot Sharing Gallery in Copilot Studio or Front-End Code Samples in Power Pages, there's a gallery for you!   Check out each community's gallery today! Power Apps Gallery Power Automate Gallery Power Pages Gallery Copilot Studio Gallery