Forums

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

Smart Value: Time to Resolution with decimals

Luca Schernbeck July 5, 2024

Hi,

I have a Jira automation in which I create a variable that calculates the time difference between 'issue.created' and 'issue.resolutiondate' to provide me with the "Time to Resolution" in hours and days respectively. Here is what it currently looks like:


{{issue.created.diff(issue.resolutiondate).hours}}

{{issue.created.diff(issue.resolutiondate).days}}

 

This is working fine, but I noticed that when the time to resolution is less than 24 hours, the time to resolution in days is just 0.
I would like to adjust the above code so that the output uses 2 decimal places, e.g. 0.25.

I've went through the smart value documentation but wasn't able to find any formatting for decimal places.

Thanks for your help.

1 answer

1 accepted

0 votes
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.
July 5, 2024 edited

Hi @Luca Schernbeck -- Welcome to the Atlassian Community!

The diff() function for date / time values always returns an integer value...and I believe may use some floor, ceiling, or rounding, based upon the units of measure for the diff.

When you want the fractional part, you could use a smaller unit of measure and a math operation to adjust the display: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/#Functions

For example, to get the fractional days to a second resolution:

{{#=}}ROUND( {{issue.created.diff(issue.resolutiondate).seconds}} / 86400, 2){{/}}

And if you need that value to always display 2 digits of precision, you could first store that value with Create Variable, and then pretty print it with format():

{{varMyDiffValue.asNumber.format("#.##")}}

Kind regards,
Bill

Luca Schernbeck July 9, 2024

This worked perfectly, thank you @Bill Sheboy!

Like Bill Sheboy likes this

Suggest an answer

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

Atlassian Community Events