Forums

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

How to calculate the 2 system date fields in jira like create date and updated date

Madhu April 18, 2023

How to calculate the 2 system date fields in Jira like create date and updated date

I have written below code  for calculating the two system fields.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue;
import java.util.Date.*

def createdDate = issue.getCreated()
log.warn("Date Created: " + createdDate)
def updatedDate = issue.getUpdated()
log.warn("Updated Date: " + updatedDate)
{
def daysDiff = createdDateValue - updatedDateValue
return daysDiff
}

2 answers

0 votes
Nic Brough -Adaptavist-
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 5, 2023

You'll need to convert the return value from milliseconds up to days (I think it's milliseconds, not seconds) - divide by (1000 * 60 * 60 * 24)

0 votes
Karim ABO HASHISH
Community Champion
May 5, 2023

hi @Madhu 

I can see that you are on the JIRA cloud version. could you please explain the business context or what is the final outcome/output you are expecting.

I can see also that you are trying using scriptrunner which is powerful tool by the way but you can also achieve many things easily using JIRA Automation with low code and low maintenance.

Awaiting your feedback to propose the proper solution according to your needs and context.

Cheers,

Karim

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events