Use the Subtract action to decrease the value in the Datetime variable by a specified time value and unit. For example, you can use this action to decrease the Datetime variable value by three hours or by three days.

Prerequisites

Before using the Subtract, ensure that a Datetime variable is already defined in your bot. For information on creating variables, see Create a variable .

To subtract a value from a Datetime variable, do the following:

Procedure

  1. Double-click or drag the Subtract action from the Datetime node in the Actions palette.
    using subtract action to calculate the difference
  2. Select an option from the Source date and time variable list to specify the variable that contains the value from which you want to subtract the time unit.
  3. Enter the value you want to subtract in the Time value to subtract field.
  4. Select an option from the Time unit to subtract list to specify the time unit you want to subtract.
    Choose from the following time unit options:
    • Milliseconds
    • Seconds
    • Minutes
    • Hours
    • Days
    • Weeks
    • Months
    • Years
    Note: This action accounts for leap years. For example, if the action subtracts 31 days from March 31, 2020, the action output is February 29, 2020. Whereas, if the action subtracts 31 days from March 31, 2019, the action output is February 28, 2019.
  5. Select the output Datetime variable from the Assign the output to a variable.
  6. Click Save.
    The Subtract is saved and added to the bot workflow. The output Datetime variable is updated with the calculated value when the bot runs.

Next steps

To see the output value, convert the value in the Datetime variable to a String variable, then print the value with the Message Box action. For more information, see Using the To string action and Using the Message box action.