JIRA Issue Age scripted field

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

This widget could not be displayed.

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

Thank you Chander it worked.

Is it possible to exclude the weekends?

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

This widget could not be displayed.

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

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

This issue is fixed now.

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted Aug 06, 2018 in Jira Service Desk

A is for Activate: Share your top Jira Service Desk onboarding tips for new users!

Hi, everyone! Molly here from the Jira Service Desk Product Marketing Team :).  In the spirit of this month's  august-challenge, we're sourcing stories of Jira Service Desk activation fro...

565 views 25 15
Join discussion

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