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.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.