ESQL numeric operators

The numeric operators +, -, *, /, and ||.

ESQL provides the following numeric operators:

Unary Operator -
The result is the negation of the operand (that is, it has the same magnitude as the operand but the opposite sign). You can negate numeric values (INTEGER, DECIMAL and FLOAT) and intervals (INTERVAL).
Operator +
The result is the sum of the two operands. You can add two numeric values, two intervals, and an interval to a datetime value (DATE, TIME, TIMESTAMP, GMTTIME, and GMTTIMESTAMP).
Operator -
The result is the difference between the two operands. It is possible to:
  • Subtract one numeric value from another.
  • Subtract one date-time from another. The result is an interval.
  • Subtract one interval from another. The result is an interval.
  • Subtract an interval from a datetime value. The result is a date-time.
When subtracting one date-time from another, you must indicate the type of interval required. You do this by using a qualifier consisting of parentheses enclosing the expression, followed by an interval qualifier. For example:
SET OutputRoot.XMLNS.Data.Age  = 
          (DATE '2005-03-31' - DATE '1947-10-24') YEAR TO MONTH;
Operator *
The result is the product of the two operands. You can multiply numeric values and multiply an interval by a numeric value.
Operator /
The result is the dividend of the two operands. You can divide numeric values and divide an interval by a numeric value.
Operator ||
The result is the concatenation of the two operands. You can concatenate string values (CHARACTER, BIT, and BLOB).

In all cases, if either operand is NULL, the result is NULL. If the operands are of different types, special rules apply. These are described in Implicit casts.

For examples of how you can use these operators to manipulate datetime values, see Using numeric operators with datetime values.