Forums

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

Show created vs resolved difference

Igor Ivanenko October 13, 2022

Hello,

How to display a difference between issue created date and issue resolved date using JQL. Need to display the data per issue in Confluence using Jira macro 

Thank you!

2 answers

1 accepted

2 votes
Answer accepted
Florian Bonniec
Community Champion
October 13, 2022

Hi @Igor Ivanenko 

 

You cannot as JQL return a list of issue but what you can do us to use a JIRA Issue Macro, input your JQL then display the created date and resolved date.

If you need the number of days you will have to use a calculated field in JIRA from an app. You should be able to do it with Scriptrunner.

 

Regards

Igor Ivanenko October 13, 2022

Hi Florian, thanks again. I’ve already done this but my team is looking for a column that shows the time (days) spent on a task. I tried to find it among “Columns to display”

Florian Bonniec
Community Champion
October 13, 2022

You may try to create an automation for JIRA that compute the number of days between both date and store this value in a field or even log this time against that issue and display the Time Spent.

 

Automation for JIRA is free if you are in Data Center.

https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/

Doc is for Cloud but those function should work on Server as well.

 

Regards

Igor Ivanenko October 14, 2022

Not sure if I can create this but thank you for your answers!

0 votes
Bhanu
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.
October 13, 2022

I agree with  @Florian Bonniec 

You can achieve the same with ScriptRunner for Jira as well.

I have a similar script to calculate the age of a ticket which might help you get started.

 

import com.atlassian.core.util.DateUtils

 

def createTime = issue?.getCreated()?.getTime()

def currentTime = (new Date()).getTime()

def resolvedTime = issue?.getResolutionDate()?.getTime()

 

/*

https://docs.atlassian.com/jira/server/com/atlassian/jira/issue/status/category/StatusCategory.html

https://docs.atlassian.com/jira/server/constant-values.html#com.atlassian.jira.issue.status.category.StatusCategory.COMPLETE

COMPLETE == 'done'

IN_PROGRESS == 'indeterminate'

TO_DO == 'new'

UNDEFINED == 'undefined'

*/

 

def issueCategory = issue?.getStatus().getStatusCategory().getKey()

 

// if ticket category is undefined/no category

if (issueCategory == 'undefined') {

    return 0

}

 

// if ticket category is TO_DO/new or IN_PROGRESS/indeterminate

// OR if resolvedTime is null, calculate age using ticket created time

def ageInDays = issueCategory in ['new', 'indeterminate'] || resolvedTime == null

    ? (currentTime - createTime) / 86400000 // milliseconds in a day

    : (resolvedTime - createTime) / 86400000 // milliseconds in a day

 

if (ageInDays > 90) {

    return 3

} else if (ageInDays > 60 && ageInDays <= 90) {

    return 2

} else if (ageInDays > 30 && ageInDays <= 60) {

    return 1

} else {

    return 0

}

Igor Ivanenko October 14, 2022

Thanks!

Suggest an answer

Log in or Sign up to answer