cancel
Showing results for
Did you mean:

## Get Last Day of a Month

We need a function to get in a simple way the last day of a month.

Today I do this by using below functions and works, but is so complex:

"@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) ),'-01T00:00:00Z'),-1)"

A function like startOfMonth would be amazing.

Regards,

Gustavo Moraes

Status: Under Review

This is a great idea, thank you!

Power Automate Staff
Status changed to: Under Review

This is a great idea, thank you!

Level 8

+1

We have a use case for this to present to our customers.

When can we expect this change to rollout?

Level: Power Up

There is now a startOfMonth function. To get the last day of the current month, you can simply use:

`subtractFromTime(startOfMonth(addToTime(utcNow(),1,'month')),1,'day')`

This adds a month to the current day, jumps to the first day of the next month, then subtracts a day to be at the last day of the current month.

Level: Powered On

Big thanks to @leep

The formula you posted is exactly what I needed to calculate the end of the month.  Thank you!!!  😊

Level: Power Up

[edited for additional clarity]

I'm a little confused by the need for a specific function for this.  I was able to determine if today is the last day of the month with the following:

If(Month(Today()) = Month(Today()+1), "Not Last Day Of Month""Last Day Of Month")
{In other words - If I add one day to today and it's still the same month, then this is not the last day of the month.  Otherwise, it is.}

Combined with the above determination I am able to identify the last day of this month with the following:

If this IS the last day of the month, then I'm done.

Otherwise, the last day of this month is equal to: Date(Year(Today()), Month(Today())+1,1)-1
{In other words, using the DATE function, specify the Year(of Today) and the Month(of Today) + one more month (next month), and the 1st day of next month.  Then subtract one day (equals last day of this month).

Am I missing something?
Completed Ideas