Versions Compared

Key

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

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
languagejs
linenumberstrue
{{ <Date field> | dateadd(<Number of days>units>,"d<Unit>") }}

Placeholders

PlaceholderDescriptionExample
<Date Object>Access a date fieldissue.fields.created
<Number of 
days>
units>
The number of
days
units to be added5

Examples

Code Block
{{ issue.fields.created | dateadd(5,"d") }}
Code Block
{{ issue.fields.duedate | dateadd(3,"d") }}

Context

You would typically use this code:

...

<Unit>is one of "days", "hours", "weeks" or "months" (or their equivalent: "d", "h", "w", "m")days

Examples

The output of the code snippet is a Moment.js date object which you could use to:

...

  • Set a Date/Date-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

    To include the Date/Timestamp in
    • Code Block
      languagejs
      linenumberstrue
      {{ 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
    languagejs
    linenumberstrue
    {{ 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
      languagejs
      linenumberstrue
      Your issue will be resolved on/before {{ now | dateadd(6,"hours") }}


  • Write a JQL search expression

    of Link

    in the Link issues to current

    to

    issue

    In a conditional execution script toRun a

    post-function

    on comparing two Timestamps
  • Unlink issues based on a date comparison

Use cases

  • - Eg: Link issues whose "Planned Delivery date" is less than two days

    Code Block
    languagejs
    linenumberstrue
    {{ issue.fields["Planned Delivery Date"] < now | dateadd(2,"d") | date('YYYY-MM-DD') }}


References

Filter by label (Content by label)
showLabelsfalse
max5
spacesKB
showSpacefalse
sortmodified
reversetrue
typepage
cqllabel = "jmwe-nunjucks" and type = "page" and space = "KBJMWEC"
labelsjmwe-nunjucks jmwe-cloud

...