Previous
Previous
 
Next
Next

Datetime/Interval Arithmetic

You can perform several arithmetic operations on date (DATETIME), timestamp (TIMESTAMP, TIMESTAMP_TZ, and TIMESTAMP_LTZ) and interval (DSINTERVAL and YMINTERVAL) data. Oracle calculates the results based on the following rules:

Table: Matrix of Datetime Arithmetic is a matrix of datetime arithmetic operations. Dashes represent operations that are not supported.

Matrix of Datetime Arithmetic

Operand & Operator DATETIME TIMESTAMP INTERVAL Numeric

DATETIME

—


—


—


—


+

—


—


DATETIME

DATETIME

-

DATETIME

DATETIME

DATETIME

DATETIME

*

—


—


—


—


/

—


—


—


—


TIMESTAMP

—


—


—


—


+

—


—


TIMESTAMP

—


-

INTERVAL

INTERVAL

TIMESTAMP

TIMESTAMP

*

—


—


—


—


/

—


—


—


—


INTERVAL

—


—


—


—


+

DATETIME

TIMESTAMP

INTERVAL

—


-

—


—


INTERVAL

—


*

—


—


—


INTERVAL

/

—


—


—


INTERVAL

Numeric

—


—


—


—


+

DATETIME

DATETIME

—


NA

-

—


—


—


NA

*

—


—


INTERVAL

NA

/

—


—


—


NA


Examples You can add an interval value expression to a start time. Consider the sample table oe.orders with a column order_date.