Power Automate addToTime() Function + Examples

This Power Automate tutorial will assist you in learning everything about the Power Automate addToTime() function, like what does mean by this function and its syntax.

Also, we will see how to add time to the second, minute (UTCNow), and hour in Power Automate. Additionally, you will get to know some more below topics:

  • How to work with Power Automate add to time day.
  • Working with Power Automate add to time week.
  • Add to time month in Power Automate.
  • How to use Power Automate add to time year.

Power Automate addToTime() Function

The addToTime() function in Microsoft Power Automate (formerly known as Microsoft Flow) is a useful expression for date and time manipulation. It allows you to add a specified time to a given date/time value.

This function is particularly handy in workflows where you need to calculate future or past dates based on a certain duration. The return value from the addToTime() function will be a timestamp plus the specified number of time units.

Regarding the addToTime expression, giving positive time intervals will add the specific time unit to the time stamp. On the other hand, negative time intervals will exclude or subtract the duration from the time stamp.

addMinutes() function in Microsoft Power Automate flow

This is a brief introduction to the Power Automate addToTime() function.

Power Automate addToTime() Syntax

Below is the syntax for a Power Automate addToTime() function:

addToTime('timestamp', interval, 'time unit', 'format')

Parameters:

  • Timestamp: It is a required field where a user can add time to the timestamp.
  • Interval: It is in the form of an integer where a particular number of time units are added.
  • Time Unit: It represents the unit of time that can be used with intervals like Second, Minute, Hour, Day, Week, Month, and Year.
  • Format: It is an optional field where a user can provide a custom timestamp format. If not provided, it will take the default format[yyyy-MM-ddTHH:mm: ss.fffffffK].

Example:

For example, I will add 1 day as a time unit to the date.

addToTime('2023-12-07T00:00:00Z', 1, 'Day')
  1. 2023-12-07T00:00:00Z = Give the timestamp as per your requirement.
  2. 1 = Specify a particular interval of time unit.
  3. Day = Provide the time unit like Second, Minute, Hour, Day, Week, Month, and Year per your need.

Here will be the output as 2023-12-08T00:00:00.0000000Z.

This is the overview of Power Automate’s addToTime() function syntax.

Power Automate addToTime Second

I will illustrate an example of Power Automate addToTime() to second in a flow.

Example:

I will add a specific number of seconds to the provided timestamp. So, the outcome will display a date and time with the additional seconds.

Let’s take a date as “2023-12-13“. To this date, I am required to add 10 seconds. Then, my result will be 2023-12-13T00:00:10.0000000, as shown below.

Microsoft Power Automate addToTime() function

So, Let’s dive into the below steps!

1. Navigate to make.powerautomate.com in the browser to open the Power Automate Home page -> Tap on +Create -> Select Instant cloud flow -> Take Manually trigger a flow and enter a flow name -> Click Create.

  • Open the trigger -> Click Add an input -> Select Date.
Power Automate addToTime() function

2.  To give the addToTime() expression in a flow, add an ‘Initialize variable’ flow action under the flow trigger. The Initialize variable stores the information of the date, and the stored values can be used during the flow.

Set the parameters of the initialized variable.

  • Name: Enter the variable name manually as Date.
  • Type: Select String datatype.
  • Value: Take the value that is given in the code below.
addToTime(triggerBody()['date'],10,'Second','F')

Click OK.

Where ‘F’ represents the format of a date.

Power Automate addToTime() expression

3.  To view the output of the Power Automate addToTime() function, we can use the Compose data operation. Add the ‘Compose’ data operation and give the value in the ‘Inputs’ section.

Inputs: Click the field -> Take the Date variable from dynamic content.

addToTime() expression in Power Automate

4. After creating the flow, Save and Test the flow manually. In the Run flow window, pick the triggered date the unit needs to be added.

addToTime() function Power Automate

5. Now the flow runs successfully, it will notify a message as ‘Your flow ran successfully.’ Then, open the ‘compose’ flow action to see the output. The outputs will display the returns of the addToTime() expression as below.

  • The current date and time will be [Friday, December 8, 2023, 12:00:00AM].
Power Automate addToTime() in seconds

This is how to add seconds to the date using the Power Automate addToTime() function.

Power Automate addToTime to utcNow Minute

In the same way, we will see about Power Automate addToTime() in the ‘Minutes’ time unit.

Example:

Similarly, I must add a designated number of minutes to the current date and time. Thus, the updated Today’s date and time will reflect its added minutes.

Assuming today’s date is “13-12-2023,” adding five minutes to the current time will result in 13-12-2023T13:05, as seen in the screenshot below. Presently, the current time is [2023-12-13T13:00].

addToTime() expression Power Automate

Look at the steps that are mentioned below:

1. In the ‘Initialize variable‘ flow action, change the addToTime() expression to add minutes to the timestamp. Give the variable properties.

  • Name: Enter the variable name manually as Date.
  • Type: Select datatype String from drop-down. 
  • Value: Give the value that is given in the code below.
Value: addToTime(utcNow(),5,'Minute','dd-MM-yyyyTHH:mm')
Power Automate addToTime formula

After that, click on OK.

2. This output will be retrieved from the compose flow action by adding minutes to the utcNow() as below.

Timestamp: 08-12-2023T05:27, and the result will be 08-12-2023T05:32.

Power Automate addToTime() Minutes

This is about how to add minutes to the timestamp using the Power Automate addToTime() function.

Power Automate addToTime Hour

Similarly, in a flow, let’s see how to add hours to the timestamp using a Power Automate addToTime function.

Example:

I will add a specific number of hours to a given timestamp. For instance, suppose we have a timestamp of “2023-12-08” and need to add 2 hours. In that case, the resulting timestamp will be “2023-12-08T02:00:00.0000000,” as shown below.

Microsoft flow Power Automate add hours to addToTime()

Follow the steps below:

1. Inside the ‘Initialize variable‘ flow action, give Name, Type, and a Value. Take ‘Trigger date’ from the dynamic content in the Value parameter. Set the details:

  • Name: Provide the variable name manually as Date.
  • Type: Select datatype String.
  • Value: Select field -> Take Trigger date from the dynamic content.
addToTime() function in Power Automate

2. In the Compose flow action, give the addToTime() expression to add hours to the timestamp.

Inputs: Select field -> Click Expression -> Add the code below.

addToTime(variables('Date'),2,'Hour','dd-MM-yyyyTHH:mm:ss')
Power Automate addToTime() function in a flow

3. After saving the flow, pick the triggered date the unit needs to be added in the Run flow window.

Power Automate addToTime() to hour

4. Check out the timestamp retrieved from the addToTime expression in the compose outputs. The result will add the given hours to the timestamp [08-12-2023T02:00:00].

Power Automate addToTime Hour

This will be a detailed process of using the Power Automate addToTime() function to add hours to a timestamp.

Power Automate addToTime Day

Going deep into the Power Automate addToTime() function, let’s look at how to add days to the time stamp.

Follow the same steps that are mentioned in the above example:

  • Add a manual trigger flow to take the input as ‘Date.’
  • Initialize trigger date variable.
  • Provide addToTime() expression in the ‘Compose’ data operation.

Example:

This example involves adding a specific number of days to a particular timestamp. For example, if we begin with a timestamp of “2023-12-08” and intend to add two days, the resulting timestamp will be “2023-12-10,” as shown below.

Microsoft flow Power Automate addToTime() function

Follow the below given steps:

1. In the ‘Inputs’ of the compose flow action, give the expression to add days to the timestamp.

Inputs: Select the field -> Click Expression -> Add the expression given below.

addToTime(variables('Date'),2,'Day','yyyy-MM-dd')

After that, Click OK.

Power Automate addToTime Day

2. Once the flow has been saved, select the desired date for the unit to be added in the “Run flow” window. Then, click Run flow.

Power Automate addToTime[Day]

3. After running the flow successfully, open the initialized variable to see the triggered date.

  • Triggered Date: 2023-12-08
How to use Power Automate addToTime()function

4. The image below illustrates the results of the addToTime() function, which adds two days to the provided timestamp.

  • The result will be 2023-12-10.
addToTime() Day in Power Automate

This is about the Power Automate addToTime() function to add days to a timestamp.

Power Automate addToTime Week

Moreover, I will show you how to add a week to the date by using the Power Automate addToTime() function inside a flow.

Example:

This example involves adding a specific number of weeks to a particular timestamp. For example, if we begin with a timestamp of “2023-12-10” and intend to add one week(7 days), the resulting timestamp will be “2023-12-17,” as shown below.

Power Automate addToTime[Week]

To achieve this, go through the steps:

1. Change the ‘time interval and time unit’ in the addToTime() expression. Take the compose ‘Inputs‘ as given in the code below.

  • Inputs: Select the field -> Click Expression -> Give the expression given below.
Inputs: addToTime(variables('Date'),1,'Week','yyyy-MM-dd')

After giving the expression, click on OK.

Power Automate addToTime()function Week

2. Then, Save and Test the flow manually. In the Run flow window, pick a triggered date. Click Run flow.

Power Automate addToTime() function to week

3. Upon completing the flow, the output of the compose flow action will give the return values of the addToTime() function corresponding to the given date by adding one week to it. The return value will be [2023-12-17].

Add week to the addToTime Power Automate

This is the Power Automate addToTime() function overview to add a week to a timestamp.

Power Automate addToTime Month

In this section, let’s look at the example that will add a month to the timestamp using a Power Automate addToTime() function.

Example:

Let us assume the timestamp “2023-12-08“. I will date the negative value of the 2 months to this date. So, the return output will be like ”2023-10-08,” which means it will subtract the months provided in the addToTime() expression.

Power Automate addToTime negative [Month]

To work around this, follow the steps below:

1. Take ‘Month’ as a time unit in the addToTime() expression so that it will add given intervals of months to the timestamp.

Inputs: Select the field -> Click Expression -> Give the expression given below.

addToTime(variables('Date'),-2,'Month','MMMM dd, yyyy')

Then, Select OK.

The negative of 2 will subtract the specific time units from the original timestamp provided.

Power Automate addToTime() formula add Month

2. After that, Save and Test the flow manually. In the Run flow window, pick a triggered date. Click Run flow.

Power Automate addToTime[Month]

3. Look out for the timestamp retrieved from the addToTime() expression in the compose outputs, displaying the given date + specified number of time units.

  • The return output will be 2023-10-08 [October 08, 2023].

When we give the negative values as an interval for the time unit, it subtracts the duration from the time stamp.

Power Automate addToTime() expression Month

This is all about how to add a month to the date using the Power Automate addToTime() function.

Power Automate addToTime Year

Let us see the final example, i.e., adding a year to the timestamp by using a Power Automate addToTime() expression inside a flow.

Example:

Let’s give the timestamp “2023-12-01“. I need to add 10 years to the timestamp that we have taken. So, the return output will be like ”2033-12-01,” which means it will add the given years provided in the addToTime() expression to the timestamp.

Power Automate flow addToTime in Years

To do this example, follow the below given steps.

1. Similarly, change the format of addToTime() expression to include a year in it. Provide the below-given code in the ‘Inputs’ of compose.

Inputs: Click the field -> Select Expression ->Take the code given below.

getFutureTime(variables('Date'),10,'Year','dd-MM-yyyy'

Click Ok.

addToTime() function in Years in Power Automate flow

2. Once the flow has been created, save and run it. In the Runflow window, pick the triggered date you need, as shown below.

addToTime in Years in Power Automate flow

3. The Power Automate addToTime() function will give the output relevant to the expression by adding a year to the given timestamp.

  • The return value from the addToTime() expression is 01-12-2033.
Power Automate addToTime years

This is all about addToTime() expressions and how to use them in a Power Automate flow.

Conclusion

Using the Power Automate addToTime() function, we can add required time units to the date and time instead of using individual functions like addSeconds(), addMinutes(), addHours(), addDays(), etc.

From this tutorial, I hope you better understand how to use the Power Automate addToTime() expression using various examples.

Along with this, I have also covered the below topics with the addToTime() function:

  • Power Automate addToTime() second
  • Power Automate addToTime() minute
  • Power Automate addToTime() hour
  • Power Automate addToTime() day
  • Power Automate addToTime() week
  • Power Automate addToTime() month
  • Power Automate addToTime() year

Moreover, you may like some more Power Automate tutorials: