Date arithmetic expressions
- Last Updated: December 12, 2014
- 1 minute read
- OpenEdge
- Version 13.0
- Documentation
Date arithmetic expressions
Date arithmetic expressions compute the difference between date‑time expressions in terms of days or milliseconds. SQL supports these forms of date arithmetic:
- Addition and subtraction of integers to and from date‑time expressions
- Subtraction of one date-time expression from another
Syntax
|
Parameters
- date_time_expr
-
Returns a value of type
DATEorTIMEorTIMESTAMP. A single date‑time expression cannot mix data types, however. All elements of the expression must be the same data type.Date‑time expressions can contain date-time literals, but they must be converted to
DATEorTIMEusing theCAST,CONVERT, orTO_DATEfunctions. - int_expr
-
Returns an integer value. SQL interprets the integer differently depending on the data type of the date‑time expression:
- For
DATEexpressions, integers represent days - For
TIMEexpressions, integers represent milliseconds - For
TIMESTAMPexpressions, integers represent milliseconds
- For
Example
The
following example manipulates DATE values using
date arithmetic. SQL interprets integers as days and returns date
differences in units of days:
|
The following example manipulates TIME values using
date arithmetic. SQL interprets integers as milliseconds and returns
time differences in milliseconds:
|