Abstract
This code snippet adds a certain number of minutes/hours/days/weeks/months to a Date field.
Logic
Access the date and add the number of minutes/hours/days/weeks/months to it.
Snippet
Code Block | ||||
---|---|---|---|---|
| ||||
{{ <Date field> | dateadd(<Number of days>units>,"d<Unit>") }} |
Placeholders
Placeholder | Description | Example |
---|---|---|
<Date Object > | Access a date field |
|
<Number of |
units> | The number of |
units to be added | 5 |
...
<Unit> | is one of "days", "hours", "weeks" or "months" (or their equivalent: "d", "h", "w", "m") | days |
Examples
The output of this snippet is a Timestampthe code snippet is a Moment.js date object which you can could use to set :
- Set a Date/Date-
...
Use cases
...
- time picker field
...
- - Eg: Set the Due date to issue created plus 1 month in
- one of the Set Field Value post-functions
- one of the Transition issue post-functions on the transition screen, if any
in the Create issue post-function under Set fields of new issue section
Code Block language js linenumbers true {{ issue.fields.created | dateadd(1,"m") }}
Conditionally execute a post-function or Unlink issues - Eg: Check that the issue has been resolved for more than 10 days
Code Block language js linenumbers true {{ now > issue.fields.Resolved | dateadd(10,"d") }}
- Notify the customer that the issue will be resolved in 6 hours from now through the
- Comment in one of the Comment issue post-functions
Subject/HTML body/Text body of Email issue post-function
Code Block language js linenumbers true Your issue will be resolved on/before {{ now | dateadd(6,"hours") }}
Write a JQL search expression in the Link issues to current issue post-function - Eg: Link issues whose "Planned Delivery date" is less than two days
Code Block language js linenumbers true {{ issue.fields["Planned Delivery Date"] < now | dateadd(2,"d") | date('YYYY-MM-DD') }}
References
- How to insert information using Nunjucks annotations
- Accessing user created custom fields
- Accessing JIRA Standard fields
- now variable
- Date filter
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...