Calculating time to resolution using a scripted field in Script Runner

Hi,

I am looking at creating a calculated scripted field in Script runner based on the Days:Hours:Minutes to resolution.

The have managed to do this calculation to based on the numbers of days, but not down to the hours and minutes.

 

return (issue.resolutionDate != null) ? String.format("%d day(s)",(int)((issue.resolutionDate.getTime() - issue.getCreated().getTime()) /(1000*60*60*24))) : "N/A" ;

 

Thanks in advance

4 answers

Thanks, this is working as expected now.

Hello!

You may do the similar with CelesteCS Math for Confluence, which allows any calculations in Confluence, including any manipulations with table data. Date parameters and functions, like NOW() and DATE() are supported.

Assume you have a table with three columns and three rows on your page – from A1 till C3, where row 1 is the header row. The sum calculation formula for rows 2 and 3 will be simple:

SUM(Table1.A2:C3)

There is a plenty of other functions in the macro, so you may perform any calculations using formulas in EXCEL style.

Thanks!

 

Hi @djamal 

I am trying to do the same. Can you help me in getting the hours and days?

I was able to get the no of day by using resolvedDate - createdDate. 

Thank you

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Tuesday in Marketplace Apps

If you’re an Atlassian app developer, you’ll want to know about Atlas Camp!

This September 6-7, hundreds of Atlassian App developers will flock to Barcelona Spain to build skills, discover product roadmaps, meet face-to-face with the Atlassian team, and learn how to extend t...

113 views 0 3
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