How to Get Current Year in Power Automate? [With Previous and Next Year Examples]

Recently, I worked on a project for which a client asked me to use Power Automate to extract the current year, the previous year, and the following year. I used the Power Automate formatDateTime function and UtcNow function to achieve this.

In this tutorial, I will show you how to get current year in Power Automate. Additionally, we will discuss how to get the previous year and the following year using flow with different examples.

Get Current Year in Power Automate

To extract the current year, I will use the Power Automate instant cloud flow that will trigger manually. Follow the steps below:

1. Navigate to Power Automate and click + Create -> select Instant cloud flow. In the next window, provide a flow name, select “Manually trigger a flow,” and click on Create.

2. Then, add an “Initialized variable” to store the data and use it for any calculations or data management during the flow. Here, provide 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.
formatDateTime(utcNow(),'yyyy')
How to get current year in Power Automate

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

@{variables('Current year')}
Create a variable to get the current year in Power Automate

4. Now, the flow is ready. Click on the Save button. Click on Test -> Manually to test flow.

Get current year in cloud flows in Power Automate

5. Then, the outputs of the compose flow action will display the current year.

How to get the current year using Power Automate

This is how to get the current year using the Power Automate flow.

Get Previous Year in Power Automate

Similarly, based on the current date (14-10-2023) in Power Automate, I will show you how to get the previous year inside a flow.

In Power Automate, getting the previous year involves using the utcNow() function to get date and time values in UTC and formatting the date value into a year as an integer.

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

1. Select Power Automate under the App launcher. 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. Then, add an “Initialize variable” flow action for formatting date and time and provide details below:

  • Name: Set a name for a variable.
  • Type: Select datatype as ‘String’ from drop-down.
  • Value: Provide the below expression in value.
formatDateTime(utcNow(),'yyyy')
How to obtain previous year in Power Automate flow

3. Next, add a “Compose” data operation and select inputs as below.

  • Inputs: Select output from variables under dynamic content.
sub(int(variables('Previous year')),1)
Extract year from date in Power Automate

4. The Output generated from the compose flow action shows the previous year.

Power Automate get the previous year in Microsoft flow

This is how to get the previous year by the formatDateTime function in Power Automate flow.

Get Next Year in Power Automate

I will explain how to get the next or following year in a Power Automate flow based on the utcNow() function.

For getting next year by using a Power Automate flow, similarly follow the same.

Here, I will follow the exact step-by-step process to create a Power Automate flow and use this time formatDatetime() function in an initialized variable to get the current date with the year.

Then, I will use the add and int functions to convert the string year to a year integer value.

Follow the below instructions in an “Instant cloud flow”:

1. In the “Initialized variable,” provide the below expression in value with details below.

  • Name: Provide a name for a variable.
  • Type: Select datatype from the drop-down.
Value: formatDateTime(utcNow(),'yyyy')
Power Automate Get the next year in a flow

2. Then, add a “Compose” data operation and set the details below.

  • Inputs: Select from the dynamic content of the initialized variable.
add(int(variables('Next year')),1)
get manager name in sharepoint using client side people picker control

3. The outputs of a compose flow action will show next year inside a flow.

Return next year in Power Automate

This is how to extract next year from the formatDateTime() function in a Power Automate flow.

Conclusion

I hope you understand how to get the current, previous, and next year in Power Automate with various examples.

You may also like:

>

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…