shiftmonths(X;Y;E)
Returns the date-related value shifted by the number of months specified.
Syntax
shiftmonths(X;Y;E)
Input
Argument | Type | Description |
---|---|---|
X |
|
A scalar value or the name of a column containing date-related values Valid values can be of the form:
|
Y |
|
The amount of months to shift X If |
E |
|
A value of 0 or 1 that determines
how to handle end-of-the-month values of X .
Note: The day in the resultant date will never be greater than
the last day of that month, regardless of the value of
E . |
For more information, see Dates and time.
Note: Support for columns of type big integer available as of version
11.25.
Return Value
Returns the integer value (in date form) of the date value given as input, shifted by the number of months specified.
If the input values are not in one of the supported formats listed above, the function returns an erroneous or illogical output.
Example
In the Hourly U.S. Weather (1990) table
(pub.demo.weather.hourly90), you can create a computed column that
displays an integer value corresponding to the date value in the column
named date
shifted by 1 month:
<base table="pub.demo.weather.hourly90"/> <willbe name="example" value="shiftmonths(date;1;0)" label="Shift`1 Month"/> <colord cols="date,example"/>
Because
E
= 0 in this example:- For a date value of 02/27/90
(
X
=19900227), the result would be 03/27/90. - For a date value of 02/28/90
(
X
=19900228), the result would be 03/28/90. (The same day as the input date.) - For a date value of 05/31/90
(
X
=19900531), the result would be 06/30/90.
If
E
= 1 in this example:- For a date value of 02/27/90
(
X
=19900227), the result would be 03/27/90. - For a date value of 02/28/90
(
X
=19900228), the result would be 03/31/90. (The last day of the resultant month.) - For a date value of 05/31/90
(
X
=19900531), the result would be 06/30/90.