How to calculate no. of days between two date fields?
Asked by Saprem Garg:

I want to calculate the age of ticket from start to end. Please help with the JSON.

Thanks.

Saprem


Answers:
author: Valeriia_Havrylenko_SaaSJet
body: Hello [@Saprem Garg](/t5/user/viewprofilepage/user-id/5447618) ?

Maybe these materials will be helpful:

[1. API: Workflow statuses](https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-workflow-statuses/)  

[2. Time between statuses](https://marketplace.atlassian.com/apps/1221462?utm_source=Atlassian_Community&utm_medium=referral&utm_campaign=Comment_How-to-calculate-no-of-days-between-two-date-fields_20240312) add-on, which shows the Time between statuses.   
To filter tickets that were stuck in a status, use Date Ranges.   
![Time Between Satuses.jpg](https://community.atlassian.com/t5/image/serverpage/image-id/297190i445334271980447D/image-size/large?v=v2&px=999 "Time Between Satuses.jpg")

<br />

Also, in add-on you can set up **Warning time limits** and **Critical time limit** . If too much Time is spent on a specific issue, the system will send an email **notification** to you or any other user when a ticket is stuck in a status.  

![?????? ?????? 2023-12-18 ? 15.12.16.png](https://community.atlassian.com/t5/image/serverpage/image-id/297191i15CEE80A8B736342/image-dimensions/322x282?v=v2 "?????? ?????? 2023-12-18 ? 15.12.16.png")

The add-on has a [**30-day** free trial](https://marketplace.atlassian.com/apps/1221462?utm_source=Atlassian_Community&utm_medium=referral&utm_campaign=Comment_How-to-calculate-no-of-days-between-two-date-fields_20240312) version and **is free for up to 10 users.**

Please let me know if you have any questions

Hope it helps ?


author: Michael Yaroshefsky - Visor for Jira
body: Hi [@Saprem Garg](/t5/user/viewprofilepage/user-id/5447618)   

Welcome to the Atlassian Community.  

There was a similar question to yours a while back. The recommendation was to use a Script Field with a Number Field template.  

See the full answer here <https://community.atlassian.com/t5/App-Central-questions/How-calculate-number-of-days-between-created-date-a-custom-date/qaq-p/1982509>  

I hope this helps,  

<br />

Michael


author: Amay Purohit_RVS
body: Hi [@Saprem Garg](/t5/user/viewprofilepage/user-id/5447618)

Welcome to the community !!

You can use Jira Rest API's to pull this data or if you would be interested in a mktplace app for one stop solution, please take a look at

[Time in Status Reports](https://marketplace.atlassian.com/apps/1226187/time-in-status-reports?hosting=cloud&tab=overview)

The add-on provides the time in status of the entire issue workflow and there are 20+ reports in the app which help to meet a wide range of use cases.

One of the many reports is the Time between statuses as shown below, where you can specify your from and to statuses and the app will calculate the time between them, which should meet your requirements.

[More details here](https://community.atlassian.com/t5/App-Central/Time-in-Status-Reports/ba-p/2348133)

Do try it out.

Disclaimer : I work for RVS, the vendor for this app

![TIS - Cycle Time report.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/317433iCCEF39C09F30CC3F/image-size/large?v=v2&px=999 "TIS - Cycle Time report.PNG")


author: Hannes Obweger - JXL for Jira
body: Hi [@Saprem Garg](/t5/user/viewprofilepage/user-id/5447618)

welcome to the community!

If you want to do this in native Jira, I believe you have to use [Jira Automation](https://www.atlassian.com/software/jira/features/automation) and write the result into a custom field. I can't advice on the details, but [this](https://confluence.atlassian.com/jirakb/how-to-use-automation-to-get-the-time-an-issue-was-in-a-status-1167838219.html) may be a good starting point.

As you've surely noticed by now, there are also a number of Marketplace apps that operate in this space. Just be aware that you can trial ++any++ Marketplace app for free for 1 month - so if an app is an option for you, perhaps try a few and see which one works best for you.

On this note, here's another app that you might like: [JXL for Jira](https://marketplace.atlassian.com/apps/1224710?hosting=cloud&tab=overview&utm_source=atlassian-community&utm_medium=referral&utm_content=2633392).

JXL is a full-fledged spreadsheet/table view for your issues that allows viewing, inline-editing, sorting, and filtering by all your issue fields, much like you'd do in e.g. Excel or Google Sheets. It also comes with a number of so-called *history columns* that aren't natively available, including *time in \[status\]* , *time between \[status\] and \[status\]* , *time between created and resolved*, and many more.

This is how it looks in action:

![time-between-created-and-resolved.gif](https://community.atlassian.com/t5/image/serverpage/image-id/311036iB98D1DC824A0BE3F/image-size/large?v=v2&px=999 "time-between-created-and-resolved.gif")

As you can see above, you can easily sort and filter by *your* history columns, and also use them across JXL's advanced features, such as support for (configurable) *issue hierarchies* , *issue grouping* by any issue field(s), *sum-ups* , or *conditional formatting*.

*Disclaimer: I work on JXL.*

Any questions just let me know,

Best,

Hannes


author: Gizem G?k?e _OBSS_
body: Update on May 9th, 2024: Time in Status by OBSS was recently rebranded as [Timepiece](https://marketplace.atlassian.com/apps/1211756/time-in-status?hosting=cloud&tab=overview&utm_source=community&utm_medium=answer). It is still the same capable app with the same dedicated team behind it. The answer below mentions the app as "[Time in Status](https://marketplace.atlassian.com/apps/1211756/time-in-status?hosting=cloud&tab=overview&utm_source=community&utm_medium=answer)" but you can find the app in the marketplace as "[Timepiece (formerly Time in Status)](https://marketplace.atlassian.com/apps/1211756/time-in-status?hosting=cloud&tab=overview&utm_source=community&utm_medium=answer)".

Hello [@Saprem Garg](/t5/user/viewprofilepage/user-id/5447618) ,

To calculate the age of a particular ticket, you can use 3rd party applications that have been developed for this type of specific need. For your needs, [Time in Status](https://marketplace.atlassian.com/apps/1211756/time-in-status?hosting=cloud&tab=overview&utm_source=community&utm_medium=answer) which is developed by my team at OBSS, is the tool I would highly recommend. It is available for both Jira Cloud and Data Center.

Time in Status mainly allows you to see how much time each issue spent on each **status** or each **assignee**.

Time in Status offers two report types for your case:

The first one is **Status Duration** report (please see the screenshot above) which shows how much time each issue spent on each status. You can combine the time for multiple statuses to get metrics like **Issue Age, Cycle Time, Lead Time, Resolution Time** etc. ![Report Types Status Duration Report.png](https://community.atlassian.com/t5/image/serverpage/image-id/297374iE72D86867BE066ED/image-dimensions/522x155?v=v2 "Report Types Status Duration Report.png")

As an alternative approach, Time in Status also has **Duration Between Statuses** report type which shows the duration between two specific statuses. This report type also allows the user to exclude the times for "pause" statuses.

![Report Types DBS.png](https://community.atlassian.com/t5/image/serverpage/image-id/297370iCC7452996EAEABBC/image-dimensions/505x150?v=v2 "Report Types DBS.png")

For all numeric report types, you can calculate **averages** and **sums** of those durations grouped by the issue fields you select. For example total in-progress time per *team*or average resolution time per sprint, epic, week, month, issuetype, request type, etc. The ability to group by parts of dates (year, month, week, day, hour) or sprints is particularly useful here since it allows you to compare different time periods or see the trend.

![Group by priority.png](https://community.atlassian.com/t5/image/serverpage/image-id/310039i25FB6F9E7BA6FBE0/image-size/large?v=v2&px=999 "Group by priority.png")

The app calculates its reports using already existing Jira issue histories so when you install the app, you don't need to add anything to your issue workflows and you can get reports on your past issues as well. It supports both Jira, JSM and JPD projects.

Time in Status reports can be accessed through **its own reporting page, dashboard gadgets, and issue view screen tabs** . All these options can provide both calculated data tables and charts. And the app has a **REST****API** so you can get the reports from Jira UI or via REST. Also you can export the reports in to various formats easily.

![SS4.png](https://community.atlassian.com/t5/image/serverpage/image-id/303496iE00AFCC6235D34D4/image-size/large?v=v2&px=999 "SS4.png")

Visit [Time in Status](https://marketplace.atlassian.com/apps/1211756/time-in-status?hosting=cloud&tab=overview&utm_source=community&utm_medium=answer) to explore how our JIRA add-on can revolutionize your reporting process. Enjoy **a 30-day free trial** to experience the full range of features.

If you wish, you can also [schedule a live demo.](https://calendar.app.google/faQYgsEekRdFxnPj7) We will provide a comprehensive overview of the application and address any inquiries you may have.

Hope it helps,

Gizem


author: Mehmet A _Bloompeak_
body: Hi [@Saprem Garg](/t5/user/viewprofilepage/user-id/5447618)

Welcome to the Atlassian Community!

If you prefer to use a marketplace app, you can try [Status Time Reports](https://marketplace.atlassian.com/1221826) app developed by our team. It mainly provides reports and gadgets based on how much time passed in each status.

You can get age of a ticket by using**l** **ead** **time** (the time interval between the moment an issue is requested to the moment it is completed) report. Here is the [online demo link](http://status-time.bloompeak.io/demo), you can see it in action and try without installing the app. For your case, you can have a look at [Lead Time for Each Issue](https://bloompeak.atlassian.net/plugins/servlet/ac/io.bloompeak.status-time/st-report?ac.reportid=904) report.

For further details, you can have a look at [Status Time Reports How to Videos.](https://www.youtube.com/playlist?list=PLVHoaAkoFPJnG9nLkzcxG0P00ndQgimDs)

* This app has a dynamic status grouping feature so that you can generate various valuable reports as **time in status, time in assignee, status entry dates and status counts, cycle time and lead time, average/sum reports by any field(e.g. average in progress time by project, average cycle time by issue creation month)**.

* You can search issues by Project, Issue Type, Status, Assignee, Issue Creation/Resolution Date(and any other Date field) and JQL Query.
* Status durations are calculated according to the working calendar you define. Once you enter your working calendar into the app, it takes your working schedule into account too. That is, "In Progress" time of an issue opened on Friday at 5 PM and closed on Monday at 9 AM, will be a few hours rather than 3 days.
* You can set different duration formats.
* You can export reports in CSV file format and open them in MS Excel.
* You can also add this app as a gadget to your Jira dashboards and reach "Status Time" from Issue Detail page.
* You can enable/disable access to Status Time reports\&gadgets and Issue Detail page per project, users, groups or project role.

If you are looking for a completely **free** solution, you can try the limited version [Status Time Reports Free](https://marketplace.atlassian.com/apps/1222051).

Hope it helps.


Tags: cloud

jira-service-management

jira-service-management-cloud