How to Get Current and Previous Month in Power Automate?

This tutorial is about how to get current and previous month in Power Automate. I will show you some examples of how to get the current month in Power Automate and how to get the previous month in Power Automate.

Here are the examples we will see:

  1. How to get a current month number in a Power Automate.
  2. How to obtain the current month’s name in Power Automate.
  3. How to retrieve the current month’s abbreviation in Power Automate.

Get Current Month in Power Automate

In Power Automate, the formatDateTime() function is available to retrieve the current month using utcNow in a flow. With this format DateTime function, a user can display a particular format of date and time irrespective of the user’s system settings.

Formats for Month that can include in formatDateTime() function:

MMMM- Month name -October
MMM- Month abbreviation -Oct
MM-Month number -10

A step-by-step guide to get the current month in Power Automate flow:

Get current month number in Power Automate

Open a Power Automate Home page by logging through your Microsoft credentials. Next, create a manual trigger flow in Flow Studio. Then, take an Initialized variable and fill in the below details:

  • Name: Give a name for an initialized variable.
  • Type: Select datatype from the drop-down.
  • Value: Provide the below code in the value section.
int(formatDateTime(utcNow(),'MM'))
How to get the current month in Power Automate

To see the output, add a Compose data operation and take the Input value that is generated from an initialized variable.

@{variables('Current Month Number')}
Get the current month in Power Automate

Get current month name in Power Automate

Let us see how to get the current month’s name in Power Automate.

  • In the initialized variable, set the below details:
    • Name: Provide a name for an initialized variable.
    • Type: Select datatype as ‘String ‘ from the drop-down.
    • Value: Provide the below-given expression in the value column.
formatDateTime(utcNow(),'MMMM')
Power Automate Get the Current month in a flow
  • In the Compose action, take value from the dynamic content of variables as shown below:
@{variables('Current Month')}
Power Automate flow Get the Current month

Get Current Month Abbreviation in Power Automate

  • Similarly, set the Value of an initialized variable as given in the below code.
    • Name: Give a name for the variable.
    • Type: Select a data type as ‘ String ‘from the drop-down.
formatDateTime(utcNow(),'MMM')
Power Automate obtain the Current month in a flow
  • To check the output, add Compose action and give below details:
    • Inputs: Select the output value that comes with variables under dynamic content.
@{variables('Current Month')}
Retrieve current month in Power Automate
  • Once the flow has been created, click on Save and Test Manually.
Get Current Month name in Power Automate

Today’s Date is 11-10-2023 (dd-MM-yyyy) format.

The below image shows the output for the current month’s number:

Power Automate include current month in a path

The image placed below will represent the output for the current month’s name:

Power Automate formatDateTime get current month

Below shown screenshot will display the output for the current month’s abbreviation:

How to get month in various formats from date in Power Automate

This is how to get the current month in Power Automate using the formatDateTime() function.

Get Previous Month in Power Automate

Now, let us check out how to get the previous month in Power Automate. I have taken four examples based on the previous month in Power Automate.

  • How to get the previous month in Power Automate
  • Get the previous month’s name in Power Automate
  • Power Automate returning the first day of the previous month
  • How to get the last day of the previous month in Power Automate

1. Navigate to https://make.powerautomate.com/ and click on + Create -> select “Instant cloud flow”. In the next window, provide a flow name, select “Manually trigger a flow”, and click on Create.

2. Next, add an “Initialized variable” to store the value and be used during the flow. Here, provide the details below:

  • Name: Set a name for an initialized variable.
  • Type: Select datatype as String from the drop-down.
  • Value: Add the below code in value.
addToTime(utcNow(),-1,'month','yyyy-MM-dd')
How to get the previous month in Power Automate

3. Then, add a Compose data operation to check the output from an initialized variable.

  • Inputs: Select output from variables under dynamic content.
@{variables('Previous Month')}
Get the previous month in Power Automate

4. Now, the flow is ready, and we can test it. Save the flow and Click on Test -> Manually to test flow.

Use Power Automate Functions to get previous month

5. This is the output received from the compose flow action i.e. Previous Month Date.

Power Automate Get the previous month in a flow

This is how to get the previous month using the formatDateTime() in a Power Automate flow.

Get the previous month’s name using Power Automate

Similarly, here based on the current date (13-10-2023) in Power Automate, I will show you how to get the previous month’s name inside a flow.

Let us get the previous month’s name based on the utcNow() function using the add to Time formula in a Power Automate flow.

Follow the below step-by-step instructions to create an instant cloud flow:

1. Click App Launcher -> Select Power Automate and click on +Create -> Select “Instant cloud flow”. In the next window, provide a flow name, choose “Manually trigger a flow” and click on Create.

2. When the trigger is added to the flow, select an “Initialized variable” flow action and set the details below.

  • Name: Set a name for a variable.
  • Type: Select datatype as ‘String’ from drop-down.
  • Value: Provide the below expression in value.
addToTime(utcNow(),-1,'month','MMMM')
Power Automate flow Get the previous month name

3. Then, add a “Compose” data operation and give input value from the dynamic content of an initialized variable.

@{variables('Previous Month Name')}
Power Automate obtains the previous month in a flow

4. Once the flow has been created. Save it. Click on Test -> Manually to test flow.

Power Automate flow obtains the previous month name

5. The output generated from the initialized variable will display the previous month’s name.

Get the previous month name from the current date in Power Automate

This is how to work on the Power Automate formatDateTime() function to get the previous month’s name inside a flow.

Get the start day of the previous month in Power Automate

Now, I will show you how to get the start day of the previous month in a Power Automate flow based on the current date (13-10-2023).

Here, I will follow the same steps to create a Power Automate flow and I will use this time different function in an initialized variable to get the start day of the previous month.

Follow the below instructions to build a Power Automate flow.

1. In the initialized variable, provide the below expression in value and set details like:

  • Name: Provide a name for a variable.
  • Type: Select datatype from the drop-down.
  • Value: Add the below code in the value section.
startOfMonth(addToTime(utcNow(),-1,'Month'),'MMM dd,yyyy')
How to get start day of previous month in Power Automate

2. Next, add a Compose data operation to check the output from an initialized variable.

  • Inputs: Select output from dynamic content.
@{variables('Previous Month')}
 Extract start day of previous month in Power Automate

3. The outputs of compose will show the start day of a previous month inside a flow.

Power Automate flow Extract start day of previous month

This is how to extract the start day of a previous month using Power Automate flow.

Get the last day of the previous month in Power Automate

In this section, I will explain the final example i.e., Power Automate, how to get the previous month’s last day using a flow.

Follow the above-mentioned steps to create a Power Automate flow that will get the last day of the previous month using the utcNow() function in it.

This means it will get the previous month’s last day, i.e. (30- Sep-2023) with the current date (14-10-2023).

1. In the initialized variable, Add the below code in the value section.

subtractFromTime(startOfMonth(addToTime(utcNow(),0,'month')),1,'day','dddd, MMMM dd,yyyy')
Power Automate Flow Obtain previous month last day

2. Then, add a Compose data operation to check the output from an initialized variable.

@{variables('Last day')}
Power Automate Return previous month last day

3. The outputs of compose will show the last day of a previous month inside a flow.

MIcrosoft flow to Return previous month last day

This is how to get the last day of a previous month by using Power Automate functions inside a flow.

Conclusion

I hope you got an idea of how to get the current month in Power Automate. Also, I have explained how to get the previous month in Power Automate with a few examples like below:

  • Get the current month number in Power Automate
  • Get the current month’s name in Power Automate
  • Get Current Month Abbreviation in Power Automate
  • Get the previous month’s name using Power Automate
  • Get the start day of the previous month in Power Automate
  • Get the last day of the previous month in Power Automate

You may also like: