使用减去操作 - Use the Subtract 操作 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.

Automation 360

Use the Subtract 操作 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.

开始之前

Before using the Subtract, ensure that a Datetime variable is already defined in your 机器人. For information on creating variables, see 创建变量 .

关于此任务

要从日期时间变量中减去值,请执行以下操作:

过程

  1. 从操作面板中的日期时间节点,双击或拖动减去 操作。
    using subtract action to calculate the difference
  2. 从源日期和时间变量列表中选择一个选项,以指定包含要从中减去时间单位的值的变量。
  3. 在要减去的时间值字段中输入要减去的值。
  4. 从要减去的时间单位列表中选择一个选项,以指定要减去的时间单位。
    从以下时间单位选项中进行选择:
    • 毫秒
    • 秒
    • 分钟
    • 小时
    • 天
    • 周
    • 月
    • 年
    注: 此 操作 考虑了闰年。 例如,如果 操作 从 2020 年 3 月 31 日减去 31 天,则 操作 输出为 2020 年 2 月 29 日。 而如果 操作 从 2019 年 3 月 31 日减去 31 天,则 操作 输出为 2019 年 2 月 28 日。
  5. Select the output Datetime variable from the Assign the output to a variable.
  6. 单击保存。
    The Subtract is saved and added to the 机器人 workflow. The output Datetime variable is updated with the calculated value when the 机器人 runs.

下一步做什么

要查看输出值,请将日期时间变量中的值转换为字符串变量,然后使用消息框 操作 打印该值。 有关更多信息,请参阅 使用转换为字符串操作 和 使用消息框 操作。