Skip to main content

Notifications

Power Automate - Building Flows
Suggested answer

last day of next month

Posted on by 30
Hi All
 
I have a flow which runs on the last day of each month. At the moment I have to go into the flow on the first of each month and set it again for the last day. 
 
Each time the flow executes I want to store the last day of the month for next month within a variable and use the variable to trigger the flow. 
 
I'm thinking get the start of the month add two months and subtract a day. 
 
I've got the start of the month fine its just the adding two months and subtracting a day I can't get working. 
 
Any help much appreciated. 
 
Thanks
 
 
  • Suggested answer
    David_MA Profile Picture
    David_MA 7,541 on at
    last day of next month
    If you start the schedule of the flow on a month that has 31 days, and set the interval to 1 month, the flow will run on the last day regardless of the number of days in the month. 
     
    I have been testing this method for several months now and it seems to work. I cannot find this documented anywhere, but Run flows on a schedule in Power Automate - Power Automate | Microsoft Learn does note: If you run a flow on the month frequency, the flow runs on the same date each month.
  • Chriddle Profile Picture
    Chriddle 7,062 on at
    last day of next month
    Not very elegant, but I can't come up with something beter:
     
    - Schedule the flow to run once a day
    - Check if utcNow('yyyy-MM-dd') equals the following expression (last day of the current month):
    addDays(
    	startOfMonth(
    		addDays(
    			startOfMonth(utcNow()),
    			32
    		)
    	),
    	-1,
    	'yyyy-MM-dd'
    )
    - If not, terminate the flow
     
    Note that your local date must match the UTC date at the time your flow runs.
    Otherwise, things get more complicated.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #7 Community Profile Tips…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,487

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,014

Leaderboard