4. Understanding the Elements of SQL Statements : SQL Operations : Arithmetic Operations : Date and Time Arithmetic
 
Share this page                  
Date and Time Arithmetic
The following arithmetic is supported for date and time data types.
Note:  Notes:
INGRESDATE can store both absolute values and interval values.
"interval type" can be any of the ANSI forms or the INGRESDATE interval form
"absolute type" is a non-interval form
Operators that return absolute date forms:
absolute type
-
interval type
=
absolute type
absolute type
+
interval type
=
absolute type
interval type
+
absolute type
=
absolute type
The combining rules are: If either term is INGRESDATE, the result will also be INGRESDATE; otherwise, the result will be the same as the absolute term.
Operators used with intervals:
- interval type
=
interval type
 
 
+ interval type
=
interval type
 
 
absolute type
-
absolute type
=
interval type
interval type
+
interval type
=
interval type
interval type
-
interval type
=
interval type
interval type
*
numeric-expression
=
interval type
numeric-expression
*
interval type
=
interval type
interval type
/
numeric-expression
=
interval type
interval type
/
interval type
=
numeric-expression
The combining rules are:
ANSI absolute types must match to take their difference.
You cannot combine ANSI Year To Month and ANSI Day To Second intervals.
If an operand is INGRESDATE the result will also be INGRESDATE.