Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Duration of Time | Jira Work Management

Elizabeth Butler
Contributor
March 29, 2024

Hello, 

I would like to create a custom field that says how many days have past since a specific date. i.e., if I insert 3/25/24, it would display "4 days". It has been four days since 3/25/24

Is this possible? I would like to add it at the global level. BTW, I am not tech savvy at all so if this is possible, please explain it to me like I'm a child. :) 
Thank you

1 answer

0 votes
Ste Wright
Community Champion
March 29, 2024

Hi @Elizabeth Butler 

I removed your other question as it was a duplicate of this one :)

---

This is possible, but a few questions first...

  • What triggers the "days passed" rule? You'll need two dates to compare - so is it Start Date and Resolved Date, for example?
  • Do you want to display the number of days as a number, or as text (i.e including "days")?
  • As it's at a global level, I assume all custom fields will also be global (i.e not local within a Team-managed Project)?

Ste

Elizabeth Butler
Contributor
March 29, 2024

Thank you for removing, I thought it duplicated but couldnt find it. 

Could I enter a date as the trigger? The custom field is "Date of Last Visit", so I would enter March 20th, 2024 but instead of showing me the date, it showed me a number of days as in 9. 

Ste Wright
Community Champion
March 29, 2024

Hi @Elizabeth Butler 

You'd need to enter that date somewhere - so either...

  1. Another date field, or...
  2. Run the rule on a schedule - eg. once a day, and compare the date to "now"

I'll detail below the steps to do this, including the prerequisites. There are a few options included so let me know if you have any questions.

 


Prerequisites

You'll need to add a custom field to put the result of the comparison into. You can either use a...

  • Number Field - eg. 9
  • Text Field - eg. 9 days

To create the Custom Field at a global level, you'll need to be a Jira Product Admin, and then...

  1. Go to Settings (cog icon in top-right) > Issues
  2. Select Custom fields from the left-hand menu
  3. Select either a Number field, Short Text field, or Text Field (read only)
  4. Give it a name - eg. Count of Days - and create the field

For option (1) we'll also need a second date field. You can use these instructions to create this (eg. Date Compare) - but in step (3) use the field type "Date Picker" instead.

---

We'll then need the Custom Field ID(s) for the date field(s), which are used in the Automation Rules.

  1. Search for the "Date of Last Visit" field using the search box in the top-left of the Custom Fields list
  2. On the right-hand side of the field's row, select the breadcrumbs (...)
  3. Select Edit details from the drop-down menu
  4. Note the ID - it's in the URL (eg. EditCustomField!default.jspa?id=10123)
  5. Repeat this process for "Date Compare" - ID might be 10456

---

For this example rule, I'm not adding the fields to a Screen - but it is possible to do this. You would need to do this for the "Date Compare" field at least.

See the Notes section below for more information.

 


Rule Option 1 - Date Fields

If you intend to compare two date fields, use this option.

To create a global rule, you will need to be a Jira Product Admin, and then...

  1. Go to Settings (cog-icon in top-right) > System
  2. Select Global automation from the left-hand menu
  3. Select the Create rule button

Then the rule will look like this...

  • Trigger: Field value changed
    • Fields to monitor = Date Compare, Date of Last Visit
  • Condition: Issue fields condition
    • Field = Date Compare
    • Condition = is not empty
  • Condition: Issue fields condition
    • Field = Date of Last Visit
    • Condition = is not empty
  • Action: Edit Issue
    • Field = Count of Days (Number)
      • {{issue.customfield_10123.diff(issue.customfield_10456).days}}
    • Field = Count of Days (Text)
      • {{issue.customfield_10123.diff(issue.customfield_10456).prettyPrint}}

 


Rule Option 2 - Scheduled

If you intend instead to schedule this rule, you could do this instead. This option does not require a second date field, and could be run once a day to continuously count up the days across multiple issues simultaneously.

  • Trigger: Scheduled
    • Run rule every = 1 Days
    • Run a JQL search... = TRUE (check box)
      • JQL - "Date of Last Visit" is not EMPTY
    • Only include issues that have changed... = FALSE (uncheck box)
  • Action: Edit Issue
    • Field = Count of Days (Number)
      • {{issue.customfield_10123.diff(now).days}}
    • Field = Count of Days (Text)
      • {{issue.customfield_10123.diff(now).days}} days

 


Notes

  • The rules use smart values to dynamically populate the data. See more on smart values on this help page
  • I've included both field options above, but you could choose just one!
  • I've only included the required rule parameters, but you could add to these. For example, you could use additional Conditions, or modify the JQL in Option 2, to limit the scope to specific issue types, or only open issues, etc.
  • For Option 1, the second date field (Date Compare) will need to be on each relevant Screen. To see how to add this, see...
  • You could also add the "Count of Days" field(s) to a Screen, although you'd want them to be "read only". For the "Text Field (read only)" field this isn't a problem
    • For the other two types I would...
      • Add a new Screen (copy existing one)
      • Add these fields to it
      • Modify the relevant Screen Scheme to set the new Screen under the "view" issue operation
    • See more information on these help pages
    • Note that this only works for Company-managed Projects (unless you use the read only field type)

 


Lots to digest here!

Let us know your thoughts, and if you have any questions :)

Ste

 

 

 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events