...
Table plus |
---|
applyColStyleToCell | true |
---|
heading | 0 |
---|
columnTypes | s,s,s,s |
---|
multiple | false |
---|
columnAttributes | style="background:#e5e7ea;font-weight:bold,,style="background:#e5e7ea;font-weight:bold, |
---|
enableSorting | false |
---|
|
Syntax | addMonths(date, noMonths) | Package | | Alias | | Pkg Usage | | |
Description
Excerpt |
---|
|
Adds a number of months to a specified date, preserving the day of month where possible. |
Adds a number of months to a specified date, preserving the day of month where possible.
Parameters
Table plus |
---|
applyColStyleToCell | true |
---|
columnTypes | s,s,s,s |
---|
heading | 0 |
---|
multiple | false |
---|
enableSorting | false |
---|
|
Parameter name | Type | Required | Description |
---|
date | Date | Yes | Specifies a Date expression. | noMonths | Number | Yes | Number of months to add. If given a negative number, will do subtract. | |
Return Type
Date
Example
Code Block |
---|
|
function addMonthsInDesc(date d, int noMonths){
desc += "Date " + d + " + " + noMonths + " months = " + addMonths(d, noMonths) + "\n";
}
desc = "";
addMonthsInDesc("2012-01-31", 1);
addMonthsInDesc("2012-04-30", -2);
addMonthsInDesc("2013-01-31", 1);
addMonthsInDesc("2013-04-30", -2);
addMonthsInDesc("2012-01-31", 12);
addMonthsInDesc("2012-01-31", -1); |
Outputs to description:
Date 2012-01-31 00:00:00 + 1 months = 2012-02-29 00:00:00
Date 2012-04-30 00:00:00 + -2 months = 2012-02-29 00:00:00
Date 2013-01-31 00:00:00 + 1 months = 2013-02-28 00:00:00
Date 2013-04-30 00:00:00 + -2 months = 2013-02-28 00:00:00
Date 2012-01-31 00:00:00 + 12 months = 2013-01-31 00:00:00
Date 2012-01-31 00:00:00 + -1 months = 2011-12-31 00:00:00
See also
Filter by label (Content by label) |
---|
showLabels | false |
---|
max | 25 |
---|
showSpace | false |
---|
cql | label = "date_routine" and space = currentSpace ( ) |
---|
labels | array_routines |
---|
|
We've encountered an issue exporting this macro. Please try exporting this page again later.