You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 13 Next »

This function adds or subtracts month to/from any given date.

Use this function instead of simply adding n * {MONTH}, since {MONTH}is a macro equivalent to 30 * {DAY}, not taking into account that there are months with 31/28/29 days. Negative values for n are used in order to subtract instead of adding.

Syntax
addMonths(timestamp, numbersOfMonths, timeZone) #Output: Number 
Examples
Parser expressionDescription
addMonths({issue.duedate}, 3, LOCAL)

{issue.duedate} has the value: March 25th, 2011 23:15

This function adds 3 months to the issue's due date. The return value would be June 25th, 2011 23:15 as number.

addMonths({issue.cf11025}, -2, USER_LOCAL)

{issue.cf11025} has the value: March 25th, 2011 23:15

This function subtracts 2 months from the custom date-time field (with the ID 11025). The return value would be January 25th, 2011 23:15 as number.

Instead of the Jira server's local time this example uses the current user's time zone.

Additional information

Parameters used in this function

ParameterInput (data type)Description
timestamp

NUMBER

The parameter must be valid timestamp. Usually this value is retrieved from a field (e.g. due date, created date).
numberOfMonths

NUMBER

The number defined here will be the offset in moths. 

Negative values are used to substract days.

Internally JWT multiplies this value with the time macro  {MONTH} to add full days to the timestamp. Learn more about time macros.

timeZone

TIMEZONE

The time zone used for the calculation. 

Output
The function returns a NUMBER representing a timestamp.