- [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
-- Basic subtraction
f1 := 10 - 3,
-- Subtracting a negative
f2 := 10 - (-3)
;Result
| f1 BIGINT | f2 BIGINT |
|---|---|
| 7 | 13 |
- — date and time
FeatureQL
SELECT
-- Timestamp minus interval
f1 := TIMESTAMP '2021-01-02' - INTERVAL '1 DAY'
;Result
| f1 TIMESTAMP |
|---|
| 2021-01-01T00:00:00 |
- — floating-point
FeatureQL
SELECT
-- Difference of two timestamps
f1 := TIMESTAMP '2021-01-02' - TIMESTAMP '2021-01-01'
;Result
| f1 VARCHAR |
|---|
| 1 days |