ALLBASE/SQL Reference Manual (36216-90216)

234 Chapter8
Expressions
Add Months Function
Add Months Function
The Add Months function uses the keyword ADD_MONTHS to apply the addition operation to
a DATE or DATETIME expression. It is different from a simple addition operator in that it
adjusts the day field in the DATE or DATETIME value to the last day of the month if
adding the months creates an invalid date (such as '1989-02-30').
Scope
SQL Data Manipulation Statements
SQL Syntax
ADD_MONTHS (
DateExpression
, {[+
-]
IntegerValue
:HostVariable
[[INDICATOR]:
IndicatorVariable
]
?
:LocalVariable
:ProcedureParameter
})
Parameters
DateExpression
is either a DATE or DATETIME expression. See the "Expression"
section of this chapter for details on the syntax.
HostVariable
is a host variable of type INTEGER. It can be positive or negative. If
negative, the absolute value is subtracted from
Value1
.
IndicatorVariable
names an indicator variable, whose value
determines whether the associated host variable contains
a NULL value:
> = 0
the value is not NULL
< 0
the value is NULL (The value in the host variable will be
ignored.)
? indicates a dynamic parameter in a prepared SQL statement. The value of
the parameter is supplied when the statement is executed.
LocalVariable
contains a value within a procedure.
ProcedureParameter
contains a value that is passed into or out of a procedure.
Description
The Add Months function adds a duration of months to a DATE or DATETIME
expression. Only the month portion of the value is affected, and, if necessary, the year
portion. The day portion of the date is unchanged unless the result would be invalid (for