Scriptrunner scrpted duration field as Days Hours Mins


I have the following scripted field which has the aim of converting story points into days & hours.

We equate 1 story point to 1 man day, and we want to put a dashboard gadget together that will show side by side this custom field "Story Points converted to Hours" / Rolled Up Sub-task Estimates / Rolled Up Sub-task Time Spent. We want this to determine how accurate our Story Point estimating is.

import com.atlassian.core.util.DateUtils
def st_points = getCustomFieldValue("Story Points") as double
if (st_points != null){ 
   return DateUtils.getDurationString(Math.round(((st_points * (1000 * 60 * 60 * 24) / 1000))as double))


The problem -


If Story Points was set to 5.5 the scripted field will display it as 5d 12h, when in fact it should be 5d 4h (1 day on our JIRA instance equates to 8hrs)

Is there any way I could script this to take account of the JIRA working day rather than the actual 24hr day?








1 answer

2 votes

There's a couple of things wrong here.

First, Story Points are absolutely not equivalent to units of time (but we won't go any further down that bunny-hole)

Secondly, your script does not match what you have set in your time-tracking setup.  It looks like you have 8 hour days, but your script is saying that there are 24 hours a day. 

Your script needs to break down the numbers treating days and hours separately.  You'll also need to account for weeks, as most people work a 5 day week...

We have disparate teams using an agile board for programme delivery and equating Story Points as MAN DAYS is the only way to ensure consistency across the teams. I don't like it but that's the reality if where were are at. We're not agile, we're trying to be more agile-like.

Yes, its an 8hr day and a 5 day week so I had a feeling what you are suggesting is what I need. I am not a developer, so I was hoping for some practical guidance on how this could be achieved.



I'd tell your people to stop bothering with story points and do time based estimates instead, as they're wasting their time and yours.  They don't need SPs here, you'd get the benefits using fields the way they are intended and you could drop the unnecessary scripting.

But if they insist, you'll need to code differently.  (By the way, your calculation multiplies by 1000, then divides by it - that's pointless).

You need to decide on a consistent representation, with some form of baseline assumptions on what the various numbers represent.

So, something like:


  • 1 day is 8 hours
  • Your (dubious) translation is that 1 SP = 1 day
  • You expect people to put in things like 3.25 to mean "3 and a quarter days"

Then one approach might be

  • def days = (long) st_points
  • def partday = st_points - days
  • def hours = (days * 24) + (partday * 8)

And you can put that through the date/time duration you've already got.  Problem - this means you always need to display it in day:hours format.  Because the actual hours number has been clobbered just to make that work.

(This is another reason for simply using time estimates - it does all of this for you)

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Mar 13, 2019 in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


254 views 0 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you