<ac:structured-macro ac:name="table-plus" ac:schema-version="1" data-layout="default">
<ac:parameter ac:name="applyColStyleToCell">true</ac:parameter>
<ac:parameter ac:name="heading">0</ac:parameter>
<ac:parameter ac:name="columnTypes">s,s,s,s</ac:parameter>
<ac:parameter ac:name="multiple">false</ac:parameter>
<ac:parameter ac:name="columnAttributes">style="background:#e5e7ea;font-weight:bold,,style="background:#e5e7ea;font-weight:bold,</ac:parameter>
<ac:parameter ac:name="enableSorting">false</ac:parameter>
<ac:rich-text-body>
<table data-layout="default">
<colgroup>
<col style="width: 76.0px;" />
<col style="width: 410.0px;" />
<col style="width: 99.0px;" />
<col style="width: 141.0px;" />
</colgroup>
<tbody>
<tr>
<td>
<p><strong>Syntax</strong></p>
</td>
<td>
<p>addMonths(date, noMonths)</p>
</td>
<td>
<p><strong>Package</strong></p>
</td>
<td>
<p></p>
</td>
</tr>
<tr>
<td>
<p><strong>Alias</strong></p>
</td>
<td>
<p></p>
</td>
<td>
<p><strong>Pkg Usage</strong></p>
</td>
<td>
<p></p>
</td>
</tr>
</tbody>
</table>
</ac:rich-text-body>
</ac:structured-macro>
<h2>Description</h2>
<ac:structured-macro ac:name="excerpt" ac:schema-version="1" data-layout="default">
<ac:parameter ac:name="hidden">true</ac:parameter>
<ac:rich-text-body>
Adds a number of months to a specified date, preserving the day of month where possible.
</ac:rich-text-body>
</ac:structured-macro>
<p>Adds a number of months to a specified date, preserving the day of month where possible.</p>
<h2>Parameters</h2>
<ac:structured-macro ac:name="table-plus" ac:schema-version="1" data-layout="default">
<ac:parameter ac:name="applyColStyleToCell">true</ac:parameter>
<ac:parameter ac:name="columnTypes">s,s,s,s</ac:parameter>
<ac:parameter ac:name="heading">0</ac:parameter>
<ac:parameter ac:name="multiple">false</ac:parameter>
<ac:parameter ac:name="enableSorting">false</ac:parameter>
<ac:rich-text-body>
<table data-layout="default">
<colgroup>
<col style="width: 170.0px;" />
<col style="width: 97.0px;" />
<col style="width: 108.0px;" />
<col style="width: 305.0px;" />
</colgroup>
<tbody>
<tr>
<th>
<p>Parameter name</p>
</th>
<th>
<p>Type</p>
</th>
<th>
<p>Required</p>
</th>
<th>
<p>Description</p>
</th>
</tr>
<tr>
<td>
<p>date</p>
</td>
<td>
<p>Date</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Specifies a Date expression.</p>
</td>
</tr><tr>
<td>
<p>noMonths</p>
</td>
<td>
<p>Number</p>
</td>
<td>
<p>Yes</p>
</td>
<td>
<p>Number of months to add. If given a negative number, will do subtract.</p>
</td>
</tr>
</tbody></table>
</ac:rich-text-body>
</ac:structured-macro>
<h2>Return Type</h2>
<p><strong>Date</strong></p>
<h2>Example</h2>
<ac:structured-macro ac:name="code" ac:schema-version="1">
<ac:parameter ac:name="language">js</ac:parameter>
<ac:plain-text-body>
<![CDATA[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);]]>
</ac:plain-text-body>
</ac:structured-macro>
<p>Outputs to description:</p><p>Date 2012-01-31 00:00:00 + 1 months = 2012-02-29 00:00:00</p><p>Date 2012-04-30 00:00:00 + -2 months = 2012-02-29 00:00:00</p><p>Date 2013-01-31 00:00:00 + 1 months = 2013-02-28 00:00:00</p><p>Date 2013-04-30 00:00:00 + -2 months = 2013-02-28 00:00:00</p><p>Date 2012-01-31 00:00:00 + 12 months = 2013-01-31 00:00:00</p><p>Date 2012-01-31 00:00:00 + -1 months = 2011-12-31 00:00:00</p>
<h2>See also</h2>
<p><ac:structured-macro ac:name="contentbylabel" ac:schema-version="4" data-layout="default">
<ac:parameter ac:name="showLabels">false</ac:parameter>
<ac:parameter ac:name="max">25</ac:parameter>
<ac:parameter ac:name="showSpace">false</ac:parameter>
<ac:parameter ac:name="cql">label = "date_routine" and space = currentSpace ( )</ac:parameter>
<ac:parameter ac:name="labels">array_routines</ac:parameter>
</ac:structured-macro></p>