Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


UI Text Box
sizemedium
typeinfo

This function adds or subtracts years to or from any given date.


Code Block
languagebash
titleSyntax
linenumberstrue
 addYears(timestamp, numberOfYears, timeZone) #Output: Number


UI Expand
titleExamples


Parser expressionDescription


Code Block
languagebash
linenumberstrue
addYears({issue.created}, 10, LOCAL)


This example adds 10 years to the issue's creation date.


Code Block
languagebash
linenumberstrue
addYears({issue.dueDate}, -2, LOCAL)


This example subtracts 2 years from the issue's due date.


Code Block
languagebash
linenumberstrue
addYears({issue.cf12025}, 1, USER_LOCAL)


This example adds 1 year to a custom date-time field (with ID 12025).

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



Page properties
hiddentrue
StatusTech review

Status
titletodo

Style guide

Status
titletodo

Status
titletodo
Status
colourYellow
titleReady for review
Status
colourGreen
titledone
Status
colourRed
titleflagged

Page properties
hiddentrue
Short descriptionReturns a Statussubtletruetitletimestamp resultant of adding n years to the timestamp t.Output Statussubtletruetitletimestamp UI Text Box
sizemedium
typeinfo
The function returns a Statussubtletruetitletimestamp resultant of adding n years to the timestamp t.
UI Text Box
sizemedium
typetip

You should use this function instead of simply adding 12 * {MONTH} or 365 * {DAY}.

Negative values for n are used in order to subtract.

addYears(t, 10, LOCAL)

UI Expand
titleExamples
Parser expression Description
UI Text Box
typeinfo

timestamp t with value March 25th, 2011 23:15

The function will return a timestamp as a

Status
subtletrue
titlenumber
with the value: March 25th, 2021 23:15

UI Expand
titleAdditional information

Parameters used in this function

ParameterInput (data type)Description
timestamp

Status
subtletrue
titlenumber

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

Status
subtletrue
titlenumber

The number defined here will be the offset in daysyearsNegative values are used to substract dayssubtract years.

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

timeZone

Status
subtletrue
titletimezone

The time zone used for the calculation. 



true

ui-expand
titleOutput

This function returns a

Status
subtletrue
titleNumber
 representing a timestamp

Learn more about timezones
Excerpt Include
Dates, times and time zonesDates, times and time zonesnopanel
UI Text Box
typetip

Work days might depend on the time zone - it might be Sunday on the west coast of the US while at the same time it's already Monday in Australia. 

UI Expand

The output can be written into any Jira field of type Date Picker ore Date Time Picker.

Another very common use case is to use this function in one of the JWT calculated date-time fields.




Image AddedUse case and examples

Page properties report
firstcolumnUse case
headingsJWT feature, Workflow function, Field type, Automated action, Parser functions
cqllabel = "parser_func_addyears" and space = currentSpace()


Page properties
hiddentrue



Status
Tech review

Status
colourGreen
titledone

Style guide

Status
colourGreen
titledone

Status
titletodo
Status
colourYellow
titleReady for review
Status
colourGreen
titledone
Status
colourRed
titleflagged



Output
Page properties
hiddentrue


Short description

Adds or subtracts years to or from any given date.

Output

Status
subtletrue
titlenumber

Label
title