Calculate the time spent on each status and total time on a work item in Jira Cloud

Platform Notice: Cloud Only - This article only applies to Atlassian products on the cloud platform.

Summary

Learn how to create an automation that provides a way to calculate the time in status for any issue.

Solution

This automation rule example is designed to work based on the following workflow.

Workflow diagram showing the lifecycle of a support ticket.  From Open, it can move to Waiting for Approval then to level 1, 2, or 3 support, each with an In Progress status.  Tickets can also move to User Testing and finally Closed or Resolved.

According to this workflow, the issue can be resolved at any support level or escalated to the next support level.

In either case, the total time spent in the previous status will be calculated and stored in the system field belonging to that level.

Since the issue can be reopened and returned to support level one, the automation rule is designed to sum the previous time with the current time, showing the total time spent in the status over multiple iterations.

The following custom fields will need to be created before the rule can be run. The field showing the time spent on each stage is a number type, and the start date and end date are date-type custom fields:

  • Start date cf

  • End date cf

  • Time Taken at Level 1 Support

  • Time Taken at Level 2 Support

  • Time Taken at Level 3 Support

  • Time Taken at User Testing

  • Total Time Taken by All Support Levels

The following expression records the entry and exit in the Australian time zone for any given status.

1 {{now.convertToTimeZone("Australia/Sydney")}}

This automation rule calculates two kinds of totals: the time spent in each status and the total time spent on the issue from start to finish. The following expression calculates the time in each status and the total time spent on the issue.

Jira automation rule editing screen. The rule is set up to change the start date field when an issue transitions to LEVEL 1 SUPPORT. The start date is set to the current time in Sydney, Australia.
1 2 3 {{#=}}{{issue.Time Taken at User Testing}} + {{issue.End date cf.diff(issue.start date cf).abs.minutes}}{{/}} {{#=}}{{issue.Total Time Taken by All Support Levels}} + {{issue.End date cf.diff(issue.Start date cf).abs.minutes}}{{/}}

The time difference is calculated using the status entry time and status exit time. To find the status that the issue was transitioned from, the following smart expression is used

1 {{#changelog.status}}{{from}}{{/}}
Jira automation rule conditions.  The rule is configured to check if the previous status ID from the changelog equals 10104 and the current status is LEVEL 1 SUPPORT.

The status ID can be found by navigating to the global status page, https://your-site.atlassian.net/secure/admin/ViewStatuses.jspa. Hover over the 'Edit' link next to each status line and note the status ID from the URL that appears at the bottom of the page.

Currently, the automation rule calculates the time in minutes but you can change it to units as mentioned in Calculating time difference.

Copy the JSON below into a file (e.g. automation-rule.json) and import the rule to your site.

1 {"cloud":true,"rules":[{"id":6804207,"clientKey":"fd13fe83-0060-3148-9e44-0578305ad3c1","name":"Workflow-status-time-calculator using ChangeLog","state":"ENABLED","description":null,"authorAccountId":"557058:febb5479-9025-48a7-ac00-1e6f2c53d979","actor":{"type":"ACCOUNT_ID","value":"557058:f58131cb-b67d-43c7-b30d-6b58d40bd077"},"created":1656489355760,"updated":1656521586675,"trigger":{"id":"129212603","component":"TRIGGER","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.issue.event.trigger:transitioned","value":{"eventKey":"jira:issue_updated","issueEvent":"issue_generic","fromStatus":[],"toStatus":[]},"children":[],"conditions":[],"connectionId":null},"components":[{"id":"129212604","component":"CONDITION","parentId":null,"conditionParentId":null,"schemaVersion":1,"type":"jira.condition.container.block","value":null,"children":[{"id":"129212605","component":"CONDITION_BLOCK","parentId":"129212604","conditionParentId":null,"schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"129212608","component":"ACTION","parentId":"129212605","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"start date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[{"id":"129212606","component":"CONDITION","parentId":null,"conditionParentId":"129212605","schemaVersion":3,"type":"jira.issue.condition","value":{"selectedField":{"type":"ID","value":"status"},"selectedFieldType":"status","comparison":"EQUALS","compareValue":{"type":"NAME","modifier":null,"value":"Level 1 Support","multiValue":false,"source":null}},"children":[],"conditions":[],"connectionId":null},{"id":"129212607","component":"CONDITION","parentId":null,"conditionParentId":"129212605","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{#changelog.status}}{{from}}{{/}}","second":"10104","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null}],"connectionId":null},{"id":"129212609","component":"CONDITION_BLOCK","parentId":"129212604","conditionParentId":null,"schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"129212612","component":"ACTION","parentId":"129212609","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"End Date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212613","component":"ACTION","parentId":"129212609","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.refresh.issue","value":{"delayMs":null},"children":[],"conditions":[],"connectionId":null},{"id":"129212614","component":"ACTION","parentId":"129212609","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"Time Taken at User Testing"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Time Taken at User Testing}} + {{issue.End date cf.diff(issue.start date cf).abs.minutes}}{{/}}"},{"field":{"type":"NAME","value":"Total Time Taken by All Support Levels"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Total Time Taken by All Support Levels}} + {{issue.End date cf.diff(issue.Start date cf).abs.minutes}}{{/}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212615","component":"ACTION","parentId":"129212609","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"start date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[{"id":"129212610","component":"CONDITION","parentId":null,"conditionParentId":"129212609","schemaVersion":3,"type":"jira.issue.condition","value":{"selectedField":{"type":"ID","value":"status"},"selectedFieldType":"status","comparison":"EQUALS","compareValue":{"type":"NAME","modifier":null,"value":"LEVEL 1 SUPPORT","multiValue":false,"source":null}},"children":[],"conditions":[],"connectionId":null},{"id":"129212611","component":"CONDITION","parentId":null,"conditionParentId":"129212609","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{#changelog.status}}{{from}}{{/}}","second":"10216","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null}],"connectionId":null},{"id":"129212616","component":"CONDITION_BLOCK","parentId":"129212604","conditionParentId":null,"schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"129212619","component":"ACTION","parentId":"129212616","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"End Date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212620","component":"ACTION","parentId":"129212616","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.refresh.issue","value":{"delayMs":null},"children":[],"conditions":[],"connectionId":null},{"id":"129212621","component":"ACTION","parentId":"129212616","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"Time Taken at Level 1 Support"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Time Taken at Level 1 Support}} + {{issue.End date cf.diff(issue.start date cf).abs.minutes}}{{/}}"},{"field":{"type":"NAME","value":"Total Time Taken by All Support Levels"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Total Time Taken by All Support Levels}} + {{issue.End date cf.diff(issue.Start date cf).abs.minutes}}{{/}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212622","component":"ACTION","parentId":"129212616","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"start date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[{"id":"129212617","component":"CONDITION","parentId":null,"conditionParentId":"129212616","schemaVersion":3,"type":"jira.issue.condition","value":{"selectedField":{"type":"ID","value":"status"},"selectedFieldType":"status","comparison":"ONE_OF","compareValue":{"type":"NAME","modifier":null,"value":"[\"LEVEL 2 SUPPORT\",\"Resolved\"]","multiValue":true,"source":null}},"children":[],"conditions":[],"connectionId":null},{"id":"129212618","component":"CONDITION","parentId":null,"conditionParentId":"129212616","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{#changelog.status}}{{from}}{{/}}","second":"10209","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null}],"connectionId":null},{"id":"129212623","component":"CONDITION_BLOCK","parentId":"129212604","conditionParentId":null,"schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"129212626","component":"ACTION","parentId":"129212623","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"End Date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212627","component":"ACTION","parentId":"129212623","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.refresh.issue","value":{"delayMs":null},"children":[],"conditions":[],"connectionId":null},{"id":"129212628","component":"ACTION","parentId":"129212623","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"Time Taken at Level 2 Support"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Time Taken at Level 2 Support}} + {{issue.End date cf.diff(issue.start date cf).abs.minutes}}{{/}}"},{"field":{"type":"NAME","value":"Total Time Taken by All Support Levels"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Total Time Taken by All Support Levels}} + {{issue.End date cf.diff(issue.Start date cf).abs.minutes}}{{/}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212629","component":"ACTION","parentId":"129212623","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"start date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[{"id":"129212624","component":"CONDITION","parentId":null,"conditionParentId":"129212623","schemaVersion":3,"type":"jira.issue.condition","value":{"selectedField":{"type":"ID","value":"status"},"selectedFieldType":"status","comparison":"ONE_OF","compareValue":{"type":"NAME","modifier":null,"value":"[\"LEVEL 3 SUPPORT\",\"Resolved\"]","multiValue":true,"source":null}},"children":[],"conditions":[],"connectionId":null},{"id":"129212625","component":"CONDITION","parentId":null,"conditionParentId":"129212623","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{#changelog.status}}{{from}}{{/}}","second":"10211","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null}],"connectionId":null},{"id":"129212630","component":"CONDITION_BLOCK","parentId":"129212604","conditionParentId":null,"schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"129212633","component":"ACTION","parentId":"129212630","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"End Date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212634","component":"ACTION","parentId":"129212630","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.refresh.issue","value":{"delayMs":null},"children":[],"conditions":[],"connectionId":null},{"id":"129212635","component":"ACTION","parentId":"129212630","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"Time Taken at Level 3 Support"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Time Taken at Level 3 Support}} + {{issue.End date cf.diff(issue.start date cf).abs.minutes}}{{/}}"},{"field":{"type":"NAME","value":"Total Time Taken by All Support Levels"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Total Time Taken by All Support Levels}} + {{issue.End date cf.diff(issue.Start date cf).abs.minutes}}{{/}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212636","component":"ACTION","parentId":"129212630","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"start date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[{"id":"129212631","component":"CONDITION","parentId":null,"conditionParentId":"129212630","schemaVersion":3,"type":"jira.issue.condition","value":{"selectedField":{"type":"ID","value":"status"},"selectedFieldType":"status","comparison":"EQUALS","compareValue":{"type":"NAME","modifier":null,"value":"Resolved","multiValue":false,"source":null}},"children":[],"conditions":[],"connectionId":null},{"id":"129212632","component":"CONDITION","parentId":null,"conditionParentId":"129212630","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{#changelog.status}}{{from}}{{/}}","second":"10213","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null}],"connectionId":null},{"id":"129212637","component":"CONDITION_BLOCK","parentId":"129212604","conditionParentId":null,"schemaVersion":1,"type":"jira.condition.if.block","value":{"conditionMatchType":"ALL"},"children":[{"id":"129212640","component":"ACTION","parentId":"129212637","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"End Date cf"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:datetime","type":"SET","value":"{{now.convertToTimeZone(\"Australia/Sydney\")}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null},{"id":"129212641","component":"ACTION","parentId":"129212637","conditionParentId":null,"schemaVersion":1,"type":"jira.issue.refresh.issue","value":{"delayMs":null},"children":[],"conditions":[],"connectionId":null},{"id":"129212642","component":"ACTION","parentId":"129212637","conditionParentId":null,"schemaVersion":10,"type":"jira.issue.edit","value":{"operations":[{"field":{"type":"NAME","value":"Time Taken at User Testing"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Time Taken at User Testing}} + {{issue.End date cf.diff(issue.start date cf).abs.minutes}}{{/}}"},{"field":{"type":"NAME","value":"Total Time Taken by All Support Levels"},"fieldType":"com.atlassian.jira.plugin.system.customfieldtypes:float","type":"SET","value":"{{#=}}{{issue.Total Time Taken by All Support Levels}} + {{issue.End date cf.diff(issue.Start date cf).abs.minutes}}{{/}}"}],"advancedFields":null,"sendNotifications":true},"children":[],"conditions":[],"connectionId":null}],"conditions":[{"id":"129212638","component":"CONDITION","parentId":null,"conditionParentId":"129212637","schemaVersion":3,"type":"jira.issue.condition","value":{"selectedField":{"type":"ID","value":"status"},"selectedFieldType":"status","comparison":"EQUALS","compareValue":{"type":"NAME","modifier":null,"value":"Closed","multiValue":false,"source":null}},"children":[],"conditions":[],"connectionId":null},{"id":"129212639","component":"CONDITION","parentId":null,"conditionParentId":"129212637","schemaVersion":1,"type":"jira.comparator.condition","value":{"first":"{{#changelog.status}}{{from}}{{/}}","second":"10216","operator":"EQUALS"},"children":[],"conditions":[],"connectionId":null}],"connectionId":null}],"conditions":[],"connectionId":null}],"canOtherRuleTrigger":false,"notifyOnError":"FIRSTERROR","projects":[{"projectId":"10006","projectTypeKey":"service_desk"}],"labels":[],"tags":[],"ruleScope":{"resources":["ari:cloud:jira:59b8197a-2cf9-4518-a22e-2693f08776fa:project/10006"]},"writeAccessType":"UNRESTRICTED","collaborators":[]}]}

Updated on April 15, 2025

Still need help?

The Atlassian Community is here for you.