cancel
Showing results for 
Search instead for 
Did you mean: 
Michal

Sending an e-mail notification the last working day of the month

Inspired by a request from @EJack  in the following post, I've created a flow in the Power Automate, which sends an e-mail notification the last working day of the month, except holidays.

Because I can see many use case scenarios for it, I tried to publish it as a template.  Some months passed since I have submitted my flow, and it is still not available as a template. Unfortunately, there are no clear rules about submitting templates, no notification about if your template has been released to the pool of templates or rejected. I guess Microsoft still needs to work on that part a bit.

 

Where is the template?

I have published the flow at my GitHub repository. Feel free to download and import it to your tenant. But be aware that it doesn't honor any holidays but weekends only.

 

How does it work?

Let's assume that our first day of the working week is Monday, and we do not work during the weekend, on Saturday and Sunday. How would you count the last working day of the month?

First, you should find out what is the weekday on the last day of the month. Unfortunate at the time I write this article, there is no function which returns the last day of the month. You have to use the workaround described below. If you would like to have such a function in Power Automate, please vote on the user's voice here. The idea is still "under review" since December 2018. 

To get the last day of the current month, count backward one day from the first day of the next month.
You can use the formula:

 

 

 

subtractFromTime(startOfMonth(addToTime(utcNow(),1,'Month')),1,'Day')

 

 

 

or even more simple:

 

 

 

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

 

 

 

But the last day of the month can be a weekend (Saturday or Sunday). If this is so, you simply continue counting days backward until you hit Friday.
Now, when you know which day is the last working one in a given month, all you need to do is to compare if this is today. If true, you can trigger whatever action you want. 
Note: weekdays can be checked using dayOfWeek() function. It returns numbers starting from 0, which is Sunday and ending on 6, which is Saturday. 

do-until-countdown.png

To avoid unnecessary API calls, the flow is using trigger conditions which I described in the article "Trigger conditions - filling the information gap", and runs only the last 4 days of the month, which I found enough to address all possible cases. 

 

Challenge for you!

How to respect national holidays?

Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • I am a Microsoft Business Applications MVP and a Senior Manager at EY. I am a technology enthusiast and problem solver. I work/speak/blog/Vlog on Microsoft technology, including Office 365, Power Apps, Power Automate, SharePoint, and Teams Etc. I am helping global clients on Power Platform adoption and empowering them with Power Platform possibilities, capabilities, and easiness. I am a leader of the Houston Power Platform User Group and Power Automate community superuser. I love traveling , exploring new places, and meeting people from different cultures.
  • Blog site: https://ganeshsanapblogs.wordpress.com/ MCT | SharePoint, Microsoft 365 and Power Platform Consultant | Contributor on SharePoint StackExchange, Techcommunity
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Founder of SKILLFUL SARDINE, a company focused on productivity and the Power Platform. You can find me on LinkedIn: https://linkedin.com/in/manueltgomes and twitter http://twitter.com/manueltgomes. I also write at https://www.manueltgomes.com, so if you want some Power Automate, SharePoint or Power Apps content I'm your guy 🙂
  • I am the Owner/Principal Architect at Don't Pa..Panic Consulting. I've been working in the information technology industry for over 30 years, and have played key roles in several enterprise SharePoint architectural design review, Intranet deployment, application development, and migration projects. I've been a Microsoft Most Valuable Professional (MVP) 15 consecutive years and am also a Microsoft Certified SharePoint Masters (MCSM) since 2013.
  • Big fan of Power Platform technologies and implemented many solutions.
  • Passionate #Programmer #SharePoint #SPFx #M365 #Power Platform| Microsoft MVP | SharePoint StackOverflow, Github, PnP contributor
  • Web site – https://kamdaryash.wordpress.com Youtube channel - https://www.youtube.com/channel/UCM149rFkLNgerSvgDVeYTZQ/