- [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 - intervalyield a TIMESTAMPtimestamp1 - timestamp2/date1 - date2yield an INTERVAL- Order matters:
a - bis not the same asb - a
Related Functions
Examples
- — numeric
FeatureQL
SELECT
f1 := 10 - 3, -- Basic subtraction
f2 := 10 - (-3) -- Subtracting a negative
;Result
| f1 BIGINT | f2 BIGINT |
|---|---|
| 7 | 13 |
- — 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 TIMESTAMP | f2 VARCHAR |
|---|---|
| 2021-01-01T00:00:00 | 1 days |
- — floating-point
FeatureQL
SELECT
f1 := 2.5E0 - 1.0E0 -- DOUBLE operands
;Result
| f1 VARCHAR |
|---|
| 1.5 |