Adding and Subtracting Datetime Data Types
Go Up to DATE, TIME, and TIMESTAMP Data Types
The following table shows the result of adding and subtracting DATE
, TIME
, TIMESTAMP
, and numeric values. “Numeric value” refers to any value that can be cast as an exact numeric value by the database engine (for example, INTEGER
, DECIMAL
, or NUMERIC
).
Operand1 | Operator | Operand2 | Result |
---|---|---|---|
|
+ |
|
Error |
|
+ |
|
|
|
+ |
|
Error |
|
+ |
Numeric value |
|
|
+ |
|
|
|
+ |
|
Error |
|
+ |
|
Error |
|
+ |
Numeric value |
|
|
+ |
|
Error |
|
+ |
|
Error |
|
+ |
|
Error |
|
+ |
Numeric value |
|
|
– |
|
|
|
– |
|
Error |
|
– |
|
Error |
|
– |
Numeric value |
DATE: number of days; fractional part ignored |
|
– |
|
Error |
|
– |
|
|
|
– |
|
Error |
|
– |
Numeric value |
|
|
– |
|
Error |
|
– |
|
Error |
|
– |
|
|
|
– |
Numeric value |
|
Numeric value +
DATE
, TIME
, or TIMESTAMP
is symmetric to DATE
, TIME
, or TIMESTAMP
+ numeric value.