Skip to content

Add

aggregating category: arithmetic no `||` resultSize: 1

Adds all values given to the rule.

If no parameters are provided, all available inputs are added. Each parameter can be either a field reference or a static numeric value. The output type is promoted from the inputs: INT if all inputs are integers, FLOAT if any input is a float, and DATE if any input is a date. Date inputs are added as seconds, so Add(:date, 86400) advances :date by one day.

Parameters

Naddends Optional — accepts: field, INT, FLOAT

The Nth addend. May be a field reference (:f) or a static numeric literal. If no parameters are given, all available inputs are summed.

Input type

  • INT
  • FLOAT
  • DATE

Output type

  • matches-input-promotion

Returns DATE if any input is a date, FLOAT if any input is a float, otherwise INT.

Requires

  • Only one date can be given in the input.
  • A date cannot be added to a float.
  • If a float is in the input the return type will always be a float.
  • If a date is in the input, the return type will always be a date.

Examples

Sum all available inputs

Add()

Static values

Add(1, 2)

Mix of fields and constants (promotes to FLOAT)

Add(:integer1, 0.6)

Date arithmetic — advance a DATE by an INT number of seconds

Add(:date1, :integer2, 3600)

Errors

  • An unsupported type was being added to an integer or date addition
    A STRING or BOOLEAN value reached the rule. Only INT, FLOAT, and DATE are accepted.
  • Add cannot add multiple dates
    Two or more DATE inputs were supplied. Only one date is permitted per Add.
  • Add cannot add a date and a float
    A DATE input was combined with a FLOAT. Cast the float to int first.

See also

Subtract, Multiply, Divide, Days, Hours, Minutes, Seconds