Neoview SQL Reference Manual (R2.4 SP2)

ADD_MONTHS Function
The ADD_MONTHS function adds the integer number of months specified by int_expr to
datetime_expr and normalizes the result.
ADD_MONTHS is a Neoview extension.
ADD_MONTHS (datetime_expr, int_expr [, int2 ])
datetime_expr
is an expression that evaluates to a datetime value of type DATE or TIMESTAMP. The return
value is the same type as the datetime_expr. See “Datetime Value Expressions” (page 245).
int_expr
is an SQL numeric value expression of data type SMALLINT or INTEGER that specifies the
number of months. See “Numeric Value Expressions” (page 253).
int2
is an unsigned integer constant. If int2 is omitted or is the literal 0, the normalization is the
standard normalization. If int2 is the literal 1, the normalization includes the standard
normalization and if the starting day (the day part of datetime_expr) is the last day of the
starting month, then the ending day (the day part of the result value) is set to the last valid
day of the result month. See “Standard Normalization” (page 325). See “Numeric Value
Expressions” (page 253).
Examples of ADD_MONTHS
This function returns the value DATE '2007-03-31':
ADD_MONTHS(DATE '2007-02-28', 1, 1)
This function returns the value DATE '2007-03-28':
ADD_MONTHS(DATE '2007-02-28', 1, 0)
This function returns the value DATE '2008-03-28':
ADD_MONTHS(DATE '2008-02-28', 1, 1)
This function returns the timestamp '2009-02-28 00:00:00':
ADD_MONTHS(timestamp'2008-02-29 00:00:00',12,1)
334 SQL Functions and Expressions