You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi
I want to calculate the amount of time between certain workflow statuses and for the result to be in hours with 2 decimal places.
For testing I am taking the minutes since creation, dividing by 60 and putting this in a variable called hours:
{{#=}}{{now.diff(issue.created).minutes.abs}} / 60{{/}}
The variable is fine and prints to the log as {{hours}}
But I can't get the formatting to work. I tried {{hours.format("###.##")}} following the answer in this question but that produces no output at all. Any tips welcome, thanks!
Hi @Julia Foden
I was able to do this with ROUND() so you could try:
{{#=}}ROUND({{now.diff(issue.created).minutes.abs}} / 60, 2){{/}}
Best regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Julia,
Maybe try to put the word issue in front:
{{issue.hours.format("###.##")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I also tried this solution, but cannot get a custom created variable to format to display 2 decimals
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karen Kelly - did you see Bill's response above? Can you share what you have that is not working?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @John Funk ,
Yes, the rounding works perfectly but if I want to display 2 decimals on e.g. 100 like 100.00 I can get t right using a custom field format e.g.
{{issue.customfield_xxx.format("##.00")}}
But not on my custom variable {{total}}
tried everything {{total.format("##.00")}} doesn't work and {{issue.total.format("##.00")}} neither
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
ah, it might be something related to how a variable handles values - meaning it might not be natively using it as a number. But that's beyond me.
Maybe @Bill Sheboy can weigh in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Karen Kelly
Are you trying to change the stored value in the Total field or the output in some message, email, etc.?
If you are trying to change the stored value of Total, what you describe will only work if you have a text field. If it is numeric, Jira will most likely truncate any trailing, zero digits.
Or...is this a created variable? Sorry as I was unclear on you scenario.
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.
hello @Bill Sheboy ,
I created this custom variable as part of my automation, it is the sum of a few fields, I just want the output to how with 2 decimals instead of truncated. Referencing it in the summary of the issue
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for clarifying, Karen.
What I think is happening is created variables are always text type (at this time...) and so your variable needs to be converted to a number for the format() function to work. (Format can also work with date/time types...which are really number behind the scenes.)
Please try this:
{{total.asNumber.format("##.00")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.