SUB_TIMESTAMP

Use the SUB_TIMESTAMP script function to subtract time from a timestamp. The function lets you subtract up to 99 hours, minutes and seconds from the timestamp, so the result can be just over 4 days before the original timestamp.

Note: SUB_TIMESTAMP uses UTC for the calculation, and does not consider Daylight Time or Standard Time.

Tip: Use SUB_DAYS when you need to subtract days from a date.

Syntax

SUB_TIMESTAMP (Timestamp,Time)

Parameters

  • SUB_TIMESTAMP
    Subtracts hours, minutes and second from a timestamp

  • Timestamp
    Timestamp that you want to subtract time from, in YYYY-MM-DD HH:MM:SS format
    Format: script literal or script variable

  • Time
    Amount of time to subtract from the timestamp, in HH:MM:SS format
    Format: script literal or script variable
    Allowed values: 0 to 99 for each of the values in the timestamp (HH, MM and SS)

Return Code

The script function returns a timestamp in YYY-DD-MM HH:MM:SS format.


Example

The following example subtracts one second from the timestamp, and prints the (2018-12-31 23:59:59) in the activation report.

:SET &RET# = SUB_TIMESTAMP("2019-01-01 00:00:00", "00:00:01")
:
PRINT &RET#

See also: