How to add and subtract date using subtractFromTime() and addToTime() functions within Power Automate

By | September 30, 2022

In this blog, let us see how we can add and subtract an ‘x’ time unit such as second, minute, hour, day, week, month, and year into and from the existing date.

We recently had a client requirement in which, the client wanted to calculate the next follow-up date for the current customer. This operation is performed when a new Customer (Account) is to be added to CRM and customer details are to be updated in the CRM.

To achieve the above user requirement we designed a Power Automate flow that triggers the creation and modification of an account. We used the addToTime() function for this. On firing this flow, the CreatedOn field of the account is read and the addToTime() function gets applied to it. The output value gets updated in the “Next follow up” file which is filled on the account form. Please find the below syntax for the function:




  1. DATE_TIME_VALUE: It states the Date Time value in which the time is to be added
  2. INTERVAL_TIME: It represents the numeric number that defines how many seconds, minutes, hours, days, weeks, months, and years are to be added to the date
  3. TIME_UNIT: This defines which time unit (second, minute, hour, day, week, month, year) needs to be added to the existing date time
  4. OUTPUT_DATE_FORMAT: It shows the string date format in which the output of the date is to be seen


Here, we can notice that one week is created on the field of Account entity and displayed on the account entity form:

addToTime(triggerOutputs()?[‘body/createdon’],1,’Week’, ‘dd-MM-yyyy’)


Also, we can subtract second, minute, hour, day, week, month, and year from the existing date-time using the following-

subtractFromTime(triggerOutputs()?[‘body/createdon’],1,’Week’, ‘dd-MM-yyyy’)

On firing the Power Automate flow we get the following result-


Thus, in this manner, using subtractFromTime() and addToTime we can add or subtract second, minute, hour, day, week, month, or year time intervals from the existing date.