The following rules apply to arithmetic operators and Period data types:
- The interval expression must be a valid interval expression and must follow the rules of an Interval expression (see “ANSI Interval Expressions”). Otherwise, an error is reported. For example, the interval expression (DATE '2006-02-03' - DATE '2005-02-03') DAY, results in a value of 365 days which cannot fit into the default precision 2 of the interval qualifier DAY; therefore, an error is reported.
- The period arithmetic operations of adding or subtracting an Interval to or from a period or adding a period to an Interval follow the rules of DateTime expressions. Otherwise, errors are reported. See ANSI Interval Expressions for details on DateTime expression rules.
- An interval expression can be subtracted from a Period expression but not vice versa. If a Period expression is subtracted from an interval expression, an error is reported.
- For a Period expression with an element type of TIME, if the Period arithmetic operation results in a beginning bound less than the ending bound, an error is reported.
- For a period of element type DATE or TIMESTAMP, if the ending bound is UNTIL_CHANGED, the ending bound in the result ending bound is UNTIL_CHANGED. If the ending bound is not UNTIL_CHANGED and the ending bound in the result evaluates to an UNTIL_CHANGED value, an error is reported.
- For a period arithmetic operation, one of the operands must be an INTERVAL data type. Otherwise, an error is reported.