4.11. Type agnostic functions #

4.11.1. add()
4.11.2. dec()
4.11.3. inc()
4.11.4. sub()

4.11.1. add() #

Add the operands. It takes two or more operands of different types and returns the sensible result for cases that make sense. It throws an error for invalid cases. Operator + is a shortcut for this function.

For numeric arguments, it's the arithmetic addition.

For string arguments, it is equivalent to concatenation, i.e. the concat() function.

Certain combinations of datetime and numeric arguments make sense.

  • normal datetime and numeric added together results in the datetime value increased by the specified number of seconds or days, depending on whether the datetime value has valid time part or not, respectively

  • the interval subtype of datetime and numeric added together results in the datetime value increased by the specified number of seconds

  • normal datetime and the interval subtype of the datetime added together results in the normal datetime value increased by the specified time interval

  • two intervals added together results in the first interval increased by the second interval

4.11.2. dec() #

Decrement by one. It takes one numeric or datetime operand. The operator -- is the shortcut for it, either as prefix or postfix operator.

4.11.3. inc() #

Increment by one. It takes one numeric or datetime operand. The operator ++ is the shortcut for it, either as prefix or postfix operator.

4.11.4. sub() #

Subtract the second, etc. operands from the first. It takes two or more operands of different types and returns the sensible result for cases that make sense. It throws an error for invalid cases. Operator - is a shortcut for this function.

For numeric arguments, it's simply the arithmetic subtraction.

For string arguments, it throws an error.

Certain combinations of datetime and numeric arguments make sense.

  • a numeric value subtracted from a normal datetime results in the datetime value decreased by the specified number of seconds or days, depending on whether the datetime value has valid time part or not, respectively

  • a numeric value subtracted from the interval subtype of datetime results in the datetime value decreased by the specified number of seconds

  • an interval value subtracted from a normal datetime value results in the normal datetime value decreased by the specified time interval

  • two intervals subtracted results in the first interval decreased by the second interval