Forums

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

How to retrieve the total number of days between two dates?

Kalyani Adusumalli December 19, 2022

We have two customised date fields ( Date assigned and Date root cause populated )to populate the date ,how do I retrieve the total days spent (time spent )for each defect? 

Thanks!

1 answer

1 accepted

1 vote
Answer accepted
Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2022

Hi @Kalyani Adusumalli

One of the ways to achieve this is to create a number custom field and assign the value accordingly by using:

{{Date root cause populated.diff(Date assigned).days}}

in the automation rule whenever the 'Date root cause populated' is updated.

Hope this helps.

Thanks,
Vamsi

Kalyani Adusumalli December 19, 2022

Hi @Vamsi Kandala 

Thank you for the reply ,Could you please elaborate me on where I can set up the number field and assign this  "{{Date root cause populated.diff(Date assigned).days}} in Jira Workflow ?

Is it possible to set up the Filter or Dashboard for the total number of days ?

Appreciate your help!

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2022

Hi @Kalyani Adusumalli

  • Assume the custom field Ids for the dates 'Date assigned' and 'Date populated' are 'customfield_12345' and 'customfield_67890'
  • Create a new custom field of type number called 'Days spent' and let its Id be 'customfield_13579', if you have not already created
  • In the automation rule for the related project, create a new rule and select the trigger 'Field value changed'
  • In the 'Fields to monitor for changes' option, select the 'Date populated' field
  • In the 'For' option, select 'Edit issue'  
    • If you are entering the value for "Date populated' field when creating the ticket, select 'Create issue' also for the above option
  • Add the 'New action' component and select 'Edit issue'
  • Select the 'Days spent' field from the list if you see it
    • Type in 

      {{customfield_67890.diff(customfield_12345).days}}

  • If you don't see the 'Days spent' field in the list above:
    • Click on 'More options'
    • In the 'Additional fields' text area, select all and delete the default contents
    • Then type in
      {
      "fields": {
         "customfield_13579": "{{customfield_67890.diff(customfield_12345).days}}"
         }
      }
  • Click on 'Save'
  • Place the 'Days spent' field in the related 'View screen'

Check and test the automation rule by editing the ticket and updating the 'Date populated' field.  The 'Days spent' field should now have the corresponding data.

Hope this helps.

Thanks,
Vamsi

Kalyani Adusumalli December 19, 2022

Thank You @Vamsi Kandala !I will keep you updated on the outcome.

Vamsi Kandala
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 19, 2022

Hi @Kalyani Adusumalli,

You are welcome.

Yes, please.  Let us know how it turned out.

Thanks,
Vamsi

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
TAGS
AUG Leaders

Atlassian Community Events