getPastTime function(Power Automate Cloud flows)

Japanese version.

Subtract(calculate past date) from the current date and time (time zone is UTC) in the specified unit.

Units can be selected from year, month, week, day, hour, minute, and second.

It is similar to subtractFromTime function, but there is a difference between calculating from the specified date and time or from the current date and time.

This function is the reverse of getFutureTime and the positive and negative of the calculation.

Spec

getPastTime(<interval>, '<timeUnit>', '<format>')
ArgumentDefaultDescription
intervalRequired fieldSpecifies the amount by which the date/time is to be moved.
Positive values calculate in the past direction; negative values calculate in the future direction.
timeUnitRequired fieldSpecify the unit of measure for the calculation.
Year,Month,Week,Day,Hour,Minute,Second
formatyyyy-MM-ddTHH:mm:ss.fffffffKSpecifies the format of the result.

How to use

In most cases, it is used in the "value" when initializing or setting variables of type "string".

Click on the "Expression" tab, getPastTime, and the function name and () will be set in the expression field.

Specify arguments.

The first argument is the date, the second is the amount to be moved, and the third is the unit.

When using dynamic content or variables, special specifications are required.

Click on the button, and if the display looks like the following, the setting is complete.

You can change the function by clicking this purple icon.

For example, getPastTime(1, 'Day'), The day before the execution date and time (time zone is UTC) will be the result.

If you want to change the format of the result, specify the format in the third argument.

If you specify a negative number for the first argument, it will be addition(calculated to the future date and time), but since the expression is complicated, use getFutureTime.

---

Links

Date and time Functions(Power Automate Cloud flows)