- [subtraction]

All functions > MATH > - [subtraction]

Subtracts the right-hand value from the left-hand value (numeric, temporal, or interval forms).

Syntax

left - right  ·  SUBTRACT(left, right)

Notes

  • Numeric subtraction: same-type operands; returns NULL if either operand is NULL
  • timestamp - interval / date - interval yield a TIMESTAMP
  • timestamp1 - timestamp2 / date1 - date2 yield an INTERVAL
  • Order matters: a - b is not the same as b - a

Related Functions

Examples

- — numeric

FeatureQL
SELECT
    -- Basic subtraction
    f1 := 10 - 3,
    -- Subtracting a negative
    f2 := 10 - (-3)
;
Result
f1 BIGINTf2 BIGINT
713

- — date and time

FeatureQL
SELECT
    -- Timestamp minus interval
    f1 := TIMESTAMP '2021-01-02' - INTERVAL '1 DAY',
    -- Difference of two timestamps
    f2 := TIMESTAMP '2021-01-02' - TIMESTAMP '2021-01-01'
;
Result
f1 TIMESTAMPf2 VARCHAR
2021-01-01T00:00:001 days

- — floating-point

FeatureQL
SELECT
    -- DOUBLE operands
    f1 := 2.5e0 - 1.0e0
;
Result
f1 VARCHAR
1.5

Last update at: 2026/06/20 10:08:10