SUBSTRACT

All functions > MATH > SUBSTRACT

Subtracts the second number from the first and returns the result.

Syntax

SUBSTRACT(number1: T, number2: T) → T
sql

Type Parameters:

  • T: Numeric types: BIGINT, FLOAT, DOUBLE, DECIMAL (both args same type). Temporal: TIMESTAMP-INTERVAL→TIMESTAMP, TIMESTAMP-TIMESTAMP→INTERVAL, DATE-DATE→INTERVAL

Arguments

ParameterTypeRequiredDescription
number1TYesNumber to subtract from
number2TYesNumber to subtract

Returns

Same as input type - BIGINT, FLOAT, DOUBLE, or DECIMAL. For temporal: TIMESTAMP - INTERVAL → TIMESTAMP, TIMESTAMP - TIMESTAMP → INTERVAL, DATE - DATE → INTERVAL

Notes

  • Both arguments must be of the same numeric type
  • For temporal types, supports subtracting intervals and calculating differences
  • Returns NULL if either operand is NULL
  • Order matters: SUBSTRACT(a, b)SUBSTRACT(b, a)
  • Operator form: number1 - number2

See also

Examples

Last update at: 2025/10/13 10:23:46