Skip to main content

Date subtraction

Power Automate Desktop has an action called "Date Subtraction", but the actual processing converts the difference in two datetime variables to any unit, so that it goes back to the specified period from a specific date.It cannot be used as a process.

Here, we will explain how to subtract the acquired date data on a day, month, and annual basis.

Conclusion

This time, we use the action called "additional date".

It is named "addition", but you can express subtraction by adding a negative value.

There is also an action called "Date Subscription", but this is an action that strictly acquires the difference between two dates.

Details of "Date to add" action

The action has the following parameters.

Parameter namevalue
datePDF file path to be extracted as an image
AdditionThe number to be added (If you choose an old for "time units")
Time unitUnits to be added (year, month, day, etc.)

action

implemented with copy and paste

This time, as a sample, we have prepared a flow to calculate the current date and calculate 10 days before him.

Copy the following code and paste it on the edit screen of Power Automate Desktop to add the target action.

DateTime.GetCurrentDateTime.Local DateTimeFormat: DateTime.DateTimeFormat.DateAndTime CurrentDateTime=> CurrentDateTime
DateTime.Add DateTime: CurrentDateTime TimeToAdd: -10 TimeUnit: DateTime.TimeUnit.Days ResultedDate=> ResultedDate
DateTime.Subtract FromDate: CurrentDateTime SubstractDate: ResultedDate TimeUnit: DateTime.DifferenceTimeUnit.Days TimeDifference=> TimeDifference

Operate and implement Power Automate Desktop

  1. Enter "Additional date" from "Action Search".

  2. Set the parameter as follows

    Parameter namevalue
    date%CurrentDateTime%
    Addition-10
    Time unitDay
  3. By execution, the date data 10 days before the specified date is stored in a new variable.

The exception that can occur

There is no exception from this action.