+ [addition]

All functions > MATH > + [addition]

Adds two numeric values, or adds an interval to a date or timestamp.

Syntax

left + right  ·  ADD(left, right)

Function form

Numeric addition: Sum of the two numbers

ADD(number1: T, number2: T) → T
sql
ParameterTypeRequiredDescription
number1TYesFirst number to add
number2TYesSecond number to add

With:

  • T : Any numeric type

  • Both arguments must be of the same numeric type

  • Returns NULL if either operand is NULL

  • Very large finite magnitudes can overflow when using floating-point types

Temporal addition: Timestamp after adding the interval

ADD(timestamp: TIMESTAMP, interval: INTERVAL) → TIMESTAMP
sql
ParameterTypeRequiredDescription
timestampTIMESTAMPYesTimestamp to add to
intervalINTERVALYesInterval to add
  • Adding an interval to a DATE or a TIMESTAMP returns TIMESTAMP
  • Either order is accepted: timestamp + interval or interval + timestamp, and the same for DATE
  • Returns NULL if either operand is NULL

Returns: Timestamp after adding the interval

ADD(date: DATE, interval: INTERVAL) → TIMESTAMP
sql
ParameterTypeRequiredDescription
dateDATEYesDate to add to
intervalINTERVALYesInterval to add

Returns: Timestamp after adding the interval

ADD(interval: INTERVAL, timestamp: TIMESTAMP) → TIMESTAMP
sql
ParameterTypeRequiredDescription
intervalINTERVALYesInterval to add
timestampTIMESTAMPYesTimestamp to add to

Returns: Timestamp after adding the interval

ADD(interval: INTERVAL, date: DATE) → TIMESTAMP
sql
ParameterTypeRequiredDescription
intervalINTERVALYesInterval to add
dateDATEYesDate to add to

Notes

  • Numeric addition requires compatible numeric types; returns NULL if either operand is NULL
  • You can add an INTERVAL to a DATE or TIMESTAMP (and the symmetric interval-first form where the grammar allows it)
  • Very large finite magnitudes can overflow when using floating-point types

Examples

+ — numeric

FeatureQL
RETURN
    -- Basic addition
    f1 := 1 + 2,
    -- Right-hand side in parentheses
    f2 := 10 + (-3)
;
Result
f1 BIGINTf2 BIGINT
37

+ — date and time

FeatureQL
RETURN
    -- Timestamp plus interval
    f1 := TIMESTAMP '2021-01-01' + INTERVAL '1 DAY'
;
Result
f1 TIMESTAMP
2021-01-02T00:00:00

+ — floating-point

FeatureQL
RETURN
    -- DOUBLE operands
    f1 := 1.5e0 + 2.5e0
;
Result
f1 DECIMAL
4.0

ADD(...)

FeatureQL
RETURN
    -- Function call
    f1 := ADD(1, 2)
;
Result
f1 BIGINT
3

.ADD(...) — chained

FeatureQL
RETURN
    -- Integer literal: wrap in parentheses so `.ADD` applies to the value, not to the digit sequence
    f1 := (1).ADD(2),
    -- Decimal base: chain without extra parentheses
    f2 := 1.0.ADD(2),
    -- Fold left via chained `.ADD`
    f3 := (1).ADD(2).ADD(3)
;
Result
f1 BIGINTf2 DECIMALf3 BIGINT
33.06

ADD — Date and time

FeatureQL
RETURN
    -- Chained add on a timestamp
    f1 := TIMESTAMP '2021-01-01'.ADD(INTERVAL '1 DAY')
;
Result
f1 TIMESTAMP
2021-01-02T00:00:00

ADD — Edge cases

FeatureQL
RETURN
    -- Parsed duration
    f1 := TIMESTAMP '2025-09-01 12:00:00'.ADD(
        INTERVAL_PARSE('2 hours 30 minutes')
    )
;
Result
f1 TIMESTAMP
2025-09-01T14:30:00