- [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
    f1 := 10 - 3, -- Basic subtraction
    f2 := 10 - (-3) -- Subtracting a negative
;
Result
f1 BIGINTf2 BIGINT
713

- — date and time

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

- — floating-point

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

Last update at: 2026/05/26 17:22:09