cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
MitchC3
Level: Powered On

Scheduled flow to check for last day of the month in a condition

I need a condition to check if tomorrow's day value is less than today's day value (aka 28th/30th/31st -> 1st). I have a bloated workaround to check for is today the 28th in Feb, 30th in months that end in 30 days, and 31st for months that end in 31 but I think this is a lot cleaner.

 

My current condition is:

 

addDays(utcNow('dd'),1)

is less than

 

utcNow('dd')

The first code snippet is the issue. I don't know how to pull tomorrow's day value correctly.

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Scheduled flow to check for last day of the month in a condition

Hi @MitchC3 
You can use the expression below to get tommorrow's day value.
dayOfMonth(addDays(utcNow(),1))
Compare this with todays day value
dayOfMonth(utcNow())

 

Also, should you need it, I think its possible to get the end of the month using the following expression
addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

4 REPLIES 4
Super User
Super User

Re: Scheduled flow to check for last day of the month in a condition

Hi @MitchC3 
You can use the expression below to get tommorrow's day value.
dayOfMonth(addDays(utcNow(),1))
Compare this with todays day value
dayOfMonth(utcNow())

 

Also, should you need it, I think its possible to get the end of the month using the following expression
addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

View solution in original post

ahetaton
Level: Powered On

Re: Scheduled flow to check for last day of the month in a condition

Hi @LeeHarris 


So this is last day of the month? Is this work perfectly?

Is this work good if month of days is 28 or 29 or 30 or 31?

 


 

Also, should you need it, I think its possible to get the end of the month using the following expression
addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 


Super User
Super User

Re: Scheduled flow to check for last day of the month in a condition

Hi @ahetaton 

Yes, this expression should get you the end of the current month regardless of the number of days in the month.

If we break it down you can see how it is working.

 

First we get the current date using utcNow(). For this example lets say that the date is 20/01/20.

addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 

Then we get the start of the current month using startOfMonth() which gives us 01/01/20.

addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 

We then use the addDays() function to add enough days to move into the next month. In this case we are using 32 but you could use anything up to 57. This gives us the date 01/02/20.

addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 

Then we use the startOfMonth() function a second time to ensure we are at the beginning of next month which gives us 01/02/20.

addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 

Finally, to get the end of the current month we use the addDays() function a second time but use a value of -1 to subtract a single day giving us 31/01/20.

addDays(startOfMonth(addDays(startOfMonth(utcNow()),32)),-1)

 

Hope that helps.

 


Did I answer your question? Mark my post as a solution!

Proud to be a Flownaut!


Follow me on Twitter at @QG_LeeJHarris

Or on LinkedIn at in/leejharris

ahetaton
Level: Powered On

Re: Scheduled flow to check for last day of the month in a condition

Hi @LeeHarris,

 

 

This answer is very helpful, thanks! 🙂

Helpful resources

Announcements
firstImage

Power Platform Online Conference

Join us for the first ever Power Platform Online Conference!

firstImage

Incoming: New and improved badges!

Look out for new contribution recognition badges coming SOON!

firstImage

New & Improved Power Automate Community Cookbook

We've updated and improved the layout and uploading format of the Power Automate Cookbook!

thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

seventhimage

Webinars & Video Gallery

Watch & learn from the Power Automate Community Video Gallery!

Top Solution Authors
Top Kudoed Authors
Users online (5,838)