cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ScottR-MT
Advocate I
Advocate I

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
ScottR-MT
Advocate I
Advocate I

Anybody have any ideas?

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'))

ReceivedTime:

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

dayDiff:

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

Condition 2:

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

Image reference:

5.PNG6.PNG

You could consider testing this Flow on Monday.

Please take a try.

 

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.

Hi @ScottR-MT ,

 

Any updates?

 

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.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Users online (4,279)