Forums

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

Jira Automation: Show # of Days (in decimal format) Once Sub-Task Transitioned to Done status

Akash Panchal
Contributor
August 28, 2023

Hey everyone,

I'm looking to add a Jira automation rule for the following:

- IF sub-task transitioned to DONE status, THEN show the # of days it took to complete the sub-task in a field on the sub-task screen

 

I have been able to accomplish this by adding the following within a field called "Total Duration":

{{issue.created.diff(now).days}} Days

 

The problem is that this displays the following:

- Example:

- Created: 8/24/23 & 8:00AM

- Transitioned to DONE: 8/24/23 @ 5:00PM

- Total Duration: 0

 

The total duration is rounding to the nearest whole day, not showing partial days. In the example above, the sub-task took 9hrs to complete which is 9/24 --> 0.375 Days. How can I get it to show days in a decimal format?

 

Thank you!

1 answer

1 accepted

1 vote
Answer accepted
Bill Sheboy
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.
August 28, 2023

Hi @Akash Panchal 

Have you tried using either:

  • Diff on hours, and then divide to get your fractional amount, or...
  • Use a much more complicated rule, accounting for working/non-working days and hours.  Such a rule would perform multiple diff(), remove weekends and non-working hours, etc.

The approach you use will depend upon your specific scenario / needs.

And also...what you seem to be measuring is often called Lead Time (i.e., from request to completion time).  If you want the actual working time you could use the built-in Control Chart report, or do something a bit more to measure in-progress time, like with this how-to for Age of WIP: https://community.atlassian.com/t5/Automation-discussions/What-is-your-most-useful-automation-Here-is-mine/m-p/1561072#M34

Kind regards,
Bill

Akash Panchal
Contributor
August 28, 2023

@Bill Sheboy Thanks for the response. 

I was hoping that a simple change like below would work:


{{(issue.created.diff(now).minutes)/1440}} Days


Unfortunately, it doesn't. I'll look into your approach as well.

Thanks again!

Bill Sheboy
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.
August 28, 2023

With that approach, you are close.  Please try this adjustment:

{{issue.created.diff(now).minutes.divide(1440)}} Days

There are two formats for math expressions: in-line and the longer form.  However they cannot be combined, which is what you were doing.

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/ 

Akash Panchal
Contributor
August 28, 2023

The adjustment above does work, but it still seems to exclude any decimal points after the whole day value. 

Bill Sheboy
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.
August 28, 2023

My mistake: the rule is trying to "help" by using the precision from the left-most value in the expression.  We can force this like this:

{{#=}}ROUND({{issue.created.diff(now).minutes}}/1440,3){{/}}

Please adjust the 3 in the ROUND() call to your desired precision.

Akash Panchal
Contributor
August 28, 2023

@Bill Sheboy  This is perfect, I really appreciate your help. It works as expected. 

Thank you!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events