Power Automate: Quick Tips #2: Useful Date Expressions

Power automate is provide a cool function which is StartOfMonth which gets the first day of a month and it is a very cool function but they did not provide the Last Day of Month.

To get the Last day of the previous month use the below expression:

adddays(concat(add(int(addToTime(utcNow(),-1,'month','yyyy')),if(equals(addToTime(utcNow(),-1,'month','MM'), '12'), 1, 0) ),'-',add(int(addToTime(utcNow(),-1,'month','MM')),if(equals(addToTime(utcNow(),-1,'month','MM'), '12'), -11, 1) ),'-01T00:00:00Z'),-1)

To get Last day of current Month use the below expression:

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

Get First Day of the Next Month:

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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create your website with WordPress.com
Get started
%d bloggers like this: