Skip to content

Subtract

aggregating category: arithmetic no `||`

Subtracts the remaining values from the first, with date- and float-aware promotion.

Subtracts each subsequent parameter from the first. With no additional parameters, the first value is reduced by all available inputs. Date arithmetic is supported: a single date in the input keeps the output as a date, while two dates produce an integer (their difference in seconds).

Parameters

1minuend Mandatory — accepts: field, INT, FLOAT, DATE

The value to subtract from. May be a field reference or a static value.

Nsubtrahends Optional — accepts: field, INT, FLOAT, DATE

The Nth value to subtract from the minuend. May be a field reference or a static value.

Input type

  • INT
  • FLOAT
  • DATE

Output type

  • matches-input-promotion

Returns FLOAT if any input is a float; DATE if a single date is in the input; INT if two dates are in the input.

Requires

  • At most two dates can be given in the input.
  • A float cannot be subtracted from a date.
  • A date can neither be subtracted from a float nor an integer.
  • If a float is in the input the return type will always be a float.
  • If a single date is in the input, the return type will be a date.
  • If two dates are in the input, the return type will be an integer.

Examples

Subtract from all available inputs

Subtract(42)

Subtract a static value from a field

Subtract(:float, 42)

Date difference in seconds

Subtract(:date1, :date2)

Multiple subtrahends

Subtract(:integer, 1000, :float)

See also

Add, Multiply, Divide, Days, Hours, Minutes, Seconds