The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

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

Comments for this post are closed

Community moderators have prevented the ability to post new 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 Champions.
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

DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
TAGS
AUG Leaders

Atlassian Community Events