Addition (+) operator returns the algebraic sum of its operands.
Subtraction (-) operator returns the algebraic difference between its left and right operands.
Numeric values are added and subtracted according to basic rules of mathematics.
When you want to add or subtract time values, you must remember these rules:
You cannot add or subtract two DATE values but you can have a DATE value as one of the operands.
|
|
You cannot add two DATETIME values but you can subtract them.
|
|
You cannot subtract DATE or DATETIME values from an INTERVAL value.
|
|
Difference between a DATETIME and a DATE value or two DATETIME values is an INTERVAL value. If the operands have different qualifiers, the result has the qualifier of the first operand.
Arithmetic operations with DATE or DATETIME values can produce errors.
For example, if you try to add or subtract a UNITS MONTH operand to/from a date near the end of a month, you might get a compilation error - -1206. Invalid day in date.
Invalid day in date.
The day number in a DATE, DATETIME or INTERVAL value or literal must a
one- or two-digit number from 1 to 28 (or 29 in a leap year), 30, or 31,
depending on the month that accompanies it. (error code: -1206)