The only arithmetic operations that can be performed on date and
time values are addition and subtraction. If a date or time value
is the operand of addition, the other operand must be a duration. This topic
describes rules for performing date, time and timestamp arithmetic.
The specific rules governing the use of the addition operator with date
and time values follow:
- If one operand is a date, the other operand must be a date duration or
a labeled duration of years, months, or days.
- If one operand is a time, the other operand must be a time duration or
a labeled duration of hours, minutes, or seconds.
- If one operand is a timestamp, the other operand must be a duration. Any
type of duration is valid.
The rules for the use of the subtraction operator on date and time values
are not the same as those for addition because a date or time value cannot
be subtracted from a duration, and because the operation of subtracting two
date and time values is not the same as the operation of subtracting a duration
from a date or time value. The specific rules governing the use of the subtraction
operator with date and time values follow:
- If the first operand is a date, the second operand must be a date, a date
duration, a string representation of a date, or a labeled duration of years,
months, or days.
- If the second operand is a date, the first operand must be a date or a
string representation of a date.
- If the first operand is a time, the second operand must be a time, a time
duration, a string representation of a time, or a labeled duration of hours,
minutes, or seconds.
- If the second operand is a time, the first operand must be a time or string
representation of a time.
- If the first operand is a timestamp, the second operand must be a timestamp,
a string representation of a timestamp, or a duration.
- If the second operand is a timestamp, the first operand must be a timestamp
or a string representation of a timestamp.