How to Get Days of Month in Power Automate? [With Examples]

In Power Automate, getting the number of days in a specific month can be useful when building workflows that involve date calculations. For example, you might need the last day of the month for deadline setting, reporting, or recurring tasks.

In this tutorial, I will show you how to effectively work with dates in Power Automate, including how to get the number of days in a specific month, retrieve the current and previous month names, and identify the first and last days of the month.

Get Days of Month in Power Automate

I can combine date functions such as formatDateTime and addDays in Power Automate to achieve this. The general approach involves setting a reference to the first day of the next month and subtracting one day to get the last day of the target month.

To do this, follow the below steps:

1. Go to Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

power automate recurrence first day of month

2. Add an Initialize variable action. Then, provide the variable name as Date, type it as a string, and provide a date 2024-10-23 in value.

dayofmonth power automate

3. Add a Compose action and provide the below expression to get the number of days in the month; you can subtract the first day of the month from the last day of the month:

formatDateTime(subtractFromTime(addDays(formatDateTime(addToTime(variables('Date'), 1, 'Month'), 'yyyy-MM-01'), -1), 0, 'Day'), 'dd')
Get Days of Month in Power Automate

Now, click Save and run the flow manually. Once it runs successfully, click the Compose action to see the days of the month.

How to Get Days of Month in Power Automate

Get Current Month Name using Power Automate

In this example, I will show you how to get the current Month name using Power Automate.

1. Go to Power Automate and create an Instant Cloud flow. Choose the trigger flow (i.e., manually trigger a flow).

Get Current Month Name using Power Automate

2. Add a Compose action and provide the below expression to get the current Month name:

formatDateTime(utcNow(),'MMMM')
How to Get Current Month Name using Power Automate

Now, click Save and run the flow manually. Once it runs successfully, click the Compose action to see the current Month name.

How to Get Current Month Name in Power Automate

If you want a month name like Oct, use MMM, and if you want a month in number format, use MM instead of MMMM.

Get the Previous Month Using Power Automate

Suppose you are working on an expense approval flow in Power Automate. At the beginning of every month, your finance department needs a report of the expenses approved in the previous month. In this type of scenario, you are required to know the previous month. Let’s see how to get the previous month:

1. Go to Power Automate and create an Instant Cloud flow. Choose the trigger flow (i.e., manually trigger a flow).

Get the Previous Month Using Power Automate

2. Add a Compose action and provide the below expression to get the previous Month name:

formatDateTime(addToTime(utcNow(), -1, 'Month'), 'MMMM')
Get the Previous Month in Power Automate

Now, click Save and run the flow manually. Once it runs successfully, click the Compose action to see the name of the previous month.

How to Get the Previous Month Using Power Automate

Get the First Day of the Month Using Power Automate

I will show you how to get the first day of the month using Power Automate.

1. Go to Power Automate and create an Instant Cloud flow. Choose the trigger flow (i.e., manually trigger a flow).

Get the Previous Month Using Power Automate

2. Add a Compose action and provide the below expression to get the first day of the month:

How to get the First Day of the Month using Power Automate

Now, click Save and run the flow manually. Once it runs successfully, click the Compose action to see the first day of the month.

get the First Day of the Month using Power Automate

Get the Last Day of the Month Using Power Automate

To get the last day of the month in Power Automate, you can use the addDays() and formatDateTime() functions. Here’s a formula that calculates the last day of the current month:

Go to Power Automate and create an Instant Cloud flow. Choose the trigger flow (i.e., manually trigger a flow). Then Add a Compose action and provide the below expression to get the last day of the month:

formatDateTime(addDays(startOfMonth(addToTime(utcNow(), 1, 'Month')), -1), 'dddd')
Get the Last Day of the Month Using Power Automate

Save the flow and run it manually. Once it runs successfully, click the Compose action to see the last day of the month.

how to Get the Last Day of the Month in Power Automate

Get the Current Day of Week Using Power Automate

To get the current day of week flows the below steps:

In the Power Automate, create an Instant Cloud flow. Choose the trigger flow to trigger a flow manually. Then Add a Compose action and provide the below expression to get the current day of the week:

dayOfWeek(utcNow())
How to Get the Current Day of Week Using Power Automate

Save the flow and run it manually. Once it runs successfully, click the Compose action to see the current day of the week.

Get the Current Day of Week Using Power Automate

Get Current Hours Using Power Automate

To get current hours, create an Instant Cloud flow by manually trigger a flow, then add a compose action using the below expression:

formatDateTime(utcNow(),'hh:mm tt')
Get Current Hours Using Power Automate

Save the flow and run it manually. Once it runs successfully, click the Compose action to see the current hours.

How to Get Current Hours Using Power Automate

Get the First Day of Next Month in Power Automate

Imagine you work for a company that provides subscription services. The billing cycle starts on the first day of each month, and you want to automate an invoice generation process using Power Automate. You need to know by the first day of next month to do this. Now follow the below steps:

1. Go to Power Automate and create an Instant Cloud flow. Choose the trigger flow (i.e., manually trigger a flow).

Get the Previous Month Using Power Automate

2. Add a Compose action and provide the below expression to get the first day of next month:

formatDateTime(startOfMonth(addToTime(utcNow(), 1, 'Month')), 'dddd')
Get the First Day of Next Month in Power Automate

Save the flow and run it manually. Once it runs successfully, click the Compose action to see the first day of the next month.

How to Get the First Day of Next Month in Power Automate

Get the Last Day of Previous Month Using Power Automate

Now, I will tell you how to get the last day of the previous month using Power Automate.

In the Power Automate, create an Instant Cloud flow. Choose the trigger flow to trigger a flow manually. Then Add a Compose action and provide the below expression to get the current day of the week:

formatDateTime(subtractFromTime(startOfMonth(utcNow()), 1, 'Day'), 'dddd')
Get the Last Day of Previous Month Using Power Automate

Now, click Save and run the flow manually. Once it runs successfully, click the Compose action to see the days of the previous month.

How to Get the Last Day of Previous Month Using Power Automate

Get First Day of the Year Using Power Automate

To get the day of the week (like “Monday,” “Tuesday,” etc.) from a specific year using Power Automate, you can follow the below steps:

1. Go to Power Automate, click the Instant Cloud flow, enter the Flow name, and choose the trigger flow (i.e., manually trigger a flow).

Get First Day of the Year Using Power Automate

2. Add an Initialize variable action. Then, provide the variable name as varYear, type it as a string, and provide a date of 2024 in value.

How to get the first day of the current month in Power Automate

3. Add a ‘Compose’ action using the expression below, which will give us the first date of the specified year:

concat(variables('varYear'), '-01-01')
Power Automate Get First Day of the Year

4. Again, add a ‘Compose’ action and provide the expression below to get the first day of the year:

formatDateTime(outputs('Compose'),'dddd')
How to Get First Day of the Year Using Power Automate

Now, click Save and run the flow manually. Once it runs successfully, click the Compose action to see the first day of the year.

how to get first day of the year in power automate

In this tutorial, I explained various methods in Power Automate for working with dates, including retrieving the number of days in a month, getting the current and previous month’s names, and finding the first and last days of a month. These techniques utilize date functions such as formatDateTime, addDays, and subtractFromTime to perform essential date calculations.

Related Power Automate tutorials:

>

Build a High-Performance Project Management Site in SharePoint Online

User registration Power Apps canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

Power Platform Tutorial FREE PDF Download

FREE Power Platform Tutorial PDF

Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…