JIRA Issue Age scripted field

Ash
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.
May 23, 2017

Hi,

 

We are usingbelow code to get Issue agein JIRA 7.3.6

import com.atlassian.core.util.DateUtils
DateUtils.getDurationString(((new Date().getTime() - issue.getCreated().time) / 1000) as Long)

output looks like 20w 3h 23m

is there anyway we can get only days.

 

Thanks,

Ashish.

2 answers

1 accepted

0 votes
Answer accepted
Chander Inguva
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.
May 23, 2017

Hey Ashish,

Try this

import com.atlassian.core.util.DateUtils
import com.atlassian.jira.component.ComponentAccessor
def issue = ComponentAccessor.getIssueManager().getIssueObject('CIT-8991')
def x = Math.ceil(new Double((((new Date().getTime() - issue.getCreated().getTime())/(1000*24*3600)))))

 

 

 

Hope this helps

 

Regards

Chander

Ash
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.
May 24, 2017

Thank you Chander it worked.

Marc Jason Mutuc
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.
June 6, 2017

Is it possible to exclude the weekends?

Ash
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.
June 7, 2017

No, please do let us know if u figured it out

Like # people like this
0 votes
NareshBusireddy January 30, 2018

Hi Chander,

I've tried your answer in JIRA 6.3.6. Encountered an error as "Cannot invoke method getCreated() on null object" Can you please suggest how to get rid off this one. I'm using the same script that you've given above. Let me know if something need to get modify in the script.

Thanks,
Naresh

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 31, 2018

Your code is not getting an issue.  You will need to fix that.

NareshBusireddy January 31, 2018

This issue is fixed now.

Suggest an answer

Log in or Sign up to answer