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

Do you want to know how to get the current year in Power Automate? Then, read this complete tutorial to understand how to display the current year in Power Automate by applying the FormatDateTime function.

We will do the following things:

  • Get the current year in Power Automate.
  • How to get the previous year in Power Automate?
  • Get next year in Power Automate.

Recently, I worked on a project where a client required me to extract the current year, previous year, and next year in a Power Automate flow using the formatDateTime function.

According to the requirement, here, we must extract the current year, previous year, and next year using utcNow(), i.e.(14-10-2023).

For that, I will create an “Instant cloud flow” that will trigger manually in Power Automate.

Get Current Year 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. 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, here, 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

Now, I will explain how to get the next 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 same step-by-step process to create a Power Automate flow, and will 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 the next year in a Power Automate flow

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 got a clear view of how to get the current year from the utcNow() function in Power Automate. In addition to that, I have converted the year string to a year integer by the int() function.

You may also like: