Forums

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

Calculate how many days a issue is open

David Lockhart
July 21, 2016

I am trying to have a custom field show how many days a issue has been open. I am using the script runner and created a script field. I am trying to find current date - created date for the days open. Here is the script  

import com.atlassian.core.util.DateUtils

DateUtils.getDurationString(((new Date().getTime() - issue.getCreated().date) / 1000 / 3600 / 24 ) as long)

But the date is not showing up correctly. 

 

I also want to exclude issue that are in a closed status here is what i have tried to add 

import com.atlassian.core.util.DateUtils


def Status = issue.getStatusObject();
if (Status == Closed) {
return null;
}
DateUtils.getDurationString(((new Date().getTime() - issue.getCreated().date) / 1000 / 3600 / 24 ) as long)

but it comes back with an error of No such property: Closed for class: Script7* (* this number keeps growing when you press preview). 

 

This is so i can use the field in a gadget on the dashboard. 

1 answer

1 accepted

2 votes
Answer accepted
Christian Czaia _Decadis AG_
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 Champions.
June 9, 2015

What I can see that the "Estimate" field is empty. Do you have your estimation statistic set to story points for example and haven't actually added story points? In that case you won't see the completion bar...

Maybe turn your estimation statistic to issue count and see if that works?!

Cheers

Micah Mutrux
Contributor
June 25, 2015

Yep - you're dead on. Thanks.

Suggest an answer

Log in or Sign up to answer