Calculate the Number of Working Days Since a Field Was Updated


Track and calculate the number of days since a custom field was updated in a scripted field.


I want to make sure my SLA's are on target and have not gone overdue. Using this script to calculate the days since a custom scripted field was updated, I can easily keep track of my teams to ensure we are delivering in accordance with our SLA's.

Good to Know

  • The custom field should be updated at least once in the lifetime of the issue for the script to work correctly.


Jira Jira (7.7 - 8.6)

import com.atlassian.jira.component.ComponentAccessor

final String customField = "Custom Field Name"

def startDate = Calendar.instance
def endDate = Calendar.instance

def changeHistoryManager = ComponentAccessor.changeHistoryManager
def transition = changeHistoryManager.getChangeItemsForField(issue, customField)


int weekDays = 0
while (startDate.timeInMillis < endDate.timeInMillis) {
    startDate.add(Calendar.DAY_OF_MONTH, 1)
    startDate.get(Calendar.DAY_OF_WEEK) in [Calendar.SATURDAY, Calendar.SUNDAY] ? null : ++weekDays

Discovered an issue? Report it here

Suggested for you