SUBTRACT

All functions > DATE AND TIME > SUBTRACT

Returns difference between two dates or date and interval.

Signatures

Temporal subtraction

Returns: Timestamp after subtracting the interval

SUBTRACT(timestamp: TIMESTAMP, interval: INTERVAL) → TIMESTAMP
sql
ParameterTypeRequiredDescription
timestampTIMESTAMPYesTimestamp to subtract from
intervalINTERVALYesInterval to subtract

With:

  • T : Custom types: TIMESTAMP | INTERVAL

Temporal difference

Returns: Interval between the two dates/timestamps

SUBTRACT(timestamp1: TIMESTAMP, timestamp2: TIMESTAMP) → INTERVAL
sql
ParameterTypeRequiredDescription
timestamp1TIMESTAMPYesTimestamp to subtract from
timestamp2TIMESTAMPYesTimestamp to subtract

With:

  • T : Any timestamp type

Notes

  • For temporal types, supports subtracting intervals and calculating differences
  • Returns NULL if either operand is NULL
  • Order matters: SUBTRACT(a, b)SUBTRACT(b, a)
  • Operator form: number1 - number2

See also

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19