Formula to compare Due Date to Resolved Date
Asked by Serena Barker:

Hi,

I'm trying to identify the issues that were resolved before the due date and I've seen in the community that it may not be able to be done. I'm trying to use a simple filter where -

Resolved date \<= Due Date for the ones completed in time

Resolved date \> Due Date for the ones completed late

Can anyone suggest an easy workaround to make this work please? I am not a developer, just trying to do a simple filter condition.

TIA

Serena


Answers:
author: Valeriia_Havrylenko_SaaSJet
body: Hi [@Serena Barker](/t5/user/viewprofilepage/user-id/3391162) ?  

<br />

JQL doesn't offer a 'date compare' out of the box. You can compare to some relative date functions such as startOfDay(-3d) and such. But comparing two date fields like Resolution date and Due date is not possible.

As a work-around, you could create an automation rule, scheduled to run each month. This rule would compare the resolved date with due date. And in case the resolved date is \> due date, the rule can add a label 'resolved_after_due'.

Once this rule has run, you can create a report filtering on issues with the label 'resolved_after_due'.

In the automation rule you can use an Issue feld compare. For example, the rule can trigger on transition to Done.

And then the rule can check if the Due date is BEFORE the moment o firing the rule.

![Screenshot 2024-03-08 at 08.25.15.png](https://community.atlassian.com/t5/image/serverpage/image-id/310981i9CA076AE2BEDE583/image-size/large?v=v2&px=999 "Screenshot 2024-03-08 at 08.25.15.png")

If an app from the Atlassian Marketplace should become an option for you, you may want to have a look at the app that my team and I are working on, [Time Between Statuses](https://marketplace.atlassian.com/apps/1221462?utm_source=Atlassian_Marketplace&utm_medium=referral&utm_campaign=Comment_Formula-to-compare-Due-Date-to-Resolved-Date_20240802) add-on.

![?????? ?????? 2024-05-15 ? 12.54.52.png](https://community.atlassian.com/t5/image/serverpage/image-id/323787i7B5BECE37BE2231B/image-size/large?v=v2&px=999 "?????? ?????? 2024-05-15 ? 12.54.52.png")

Set up **Warning time limits** and **Critical time limit** to prevent tasks past their due date. 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. You will also see it in your workflow.

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

Add-on developed by my by SaaSJet team.   

We are offering you a [30 days of free trial](https://marketplace.atlassian.com/apps/1221462?utm_source=Atlassian_Marketplace&utm_medium=referral&utm_campaign=Comment_Formula-to-compare-Due-Date-to-Resolved-Date_20240802), and you can also [book a demo](https://meetings.hubspot.com/natalia-yordovska) with our specialist.  
Hope this helps!


author: Serena Barker
body: Hi [@Trudy Claspill](/t5/user/viewprofilepage/user-id/5309476) love the cat profile pic btw :)

Thanks for your response. I was hoping to achieve it without a third party app if possible.

The goal is to kpi how many tasks (or % of tasks) were completed on time vs after due date.

I did see some comments on other posts about using automation rules, but I must admit I was a little lost on how it worked to achieve the results. Any help you could give me would be greatly appreciated.


author: Trudy Claspill
body: Hello [@Serena Barker](/t5/user/viewprofilepage/user-id/3391162)

Comparing one issue date field to another issue date field in a JQL filter is not supported natively. It could be possible with the addition of a third party app. Are you open to considering purchasing a third party app?

What do you want to do with the results when you get them? It may also be possible to get what you want through an Automation Rule, depending on what you want to do with the results.

comments: author: Trudy Claspill
body: Hello [@Serena Barker](/t5/user/viewprofilepage/user-id/3391162)

The information provided by [@Valeriia_Havrylenko_SaaSJet](/t5/user/viewprofilepage/user-id/5162664) is one example of how you could use an Automation Rule to identify issues resolved before or after the due date and add a label value to each issue to help you get the lists for your reports. Here is an example of what they described.

1. Create a rule that uses the Schedule trigger. Set the frequency to what seems reasonable to you (maybe once per day).

![Screenshot 2024-08-02 at 8.32.54?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339739iD2EBEC17098349ED/image-dimensions/314x421?v=v2 "Screenshot 2024-08-02 at 8.32.54?AM.png")

2. Below the Occurrence portion of the trigger configuration is a section to tell the rule that you want to run a JQL filter to get issues each time the rule runs. Later in the rule you will add steps that will run against each issue retrieved. In your case you would want the issues that have a Resolved Date and a Due Date, and that don't have either of the labels that tell you the issue was resolved after the Due date or before the Due date.

The JQL I would recommend is:

```
resolutiondate is not empty and duedate is not empty and Labels not in ("resolved-after-due", "resolved-before-due", "resolved-when-due")
```

Make sure to uncheck the box below the JQL.

![Screenshot 2024-08-02 at 8.36.33?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339740i7A15D77A437790FC/image-dimensions/282x288?v=v2 "Screenshot 2024-08-02 at 8.36.33?AM.png")

3. Next you need to add steps to evaluate the relationship between the Resolved date and the Due date. Here I need you to provide a clarification - If an issue is resolved on the same day it is Due, what label do you want to apply to the issue?

I would use an If-Else Condition here.

Select the IF Condition option, then the **IF or ELSE** condition.

![Screenshot 2024-08-02 at 8.39.39?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339744iDF01AF1E4CF133FA/image-dimensions/257x162?v=v2 "Screenshot 2024-08-02 at 8.39.39?AM.png")

![Screenshot 2024-08-02 at 8.39.56?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339743iEA8DE630D4EAA660/image-dimensions/202x169?v=v2 "Screenshot 2024-08-02 at 8.39.56?AM.png")

![Screenshot 2024-08-02 at 8.42.11?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339746i2ED7EC41821270B3/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 8.42.11?AM.png")

You'll build up steps that logically perform this:

```
If Resolution is before Due
  Then add label "resolved-before-due"
Else if Resolution is after Due
  Then add label "resolved-after-due"
Else
  Add label "resolved-when-due"
```

Because the Resolved field is a date/time field and Due date is just a Date field, you have to use the Smart Values condition to format them each to a simple Jira Date so they can be compared.

![Screenshot 2024-08-02 at 8.50.32?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339751i489DF16A0ED8F7B4/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 8.50.32?AM.png")

![Screenshot 2024-08-02 at 8.50.42?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339752i6A7BADCD89B55DAD/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 8.50.42?AM.png")

![Screenshot 2024-08-02 at 8.50.58?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339753iC2E5B4F4D0B18DE2/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 8.50.58?AM.png")

![Screenshot 2024-08-02 at 8.51.07?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339750i4717F3B353AE5F7B/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 8.51.07?AM.png")

![Screenshot 2024-08-02 at 8.51.19?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339749iF7E5DFE134EB3757/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 8.51.19?AM.png")

![Screenshot 2024-08-02 at 8.51.27?AM.png](https://community.atlassian.com/t5/image/serverpage/image-id/339748i2FE88DE0F30479AD/image-size/large?v=v2&px=999 "Screenshot 2024-08-02 at 8.51.27?AM.png")

The above rule would look at all the issues in the target project when both fields are set and the Labels field has not already had a label added to indicate the relationship between Resolved and Due.

If either of those fields changed, this rule would not update the issue again unless the "resolved-..." Label was removed.

You might want a second rule that is triggered by the Due date field being changed, to then remove the "resolved-" label if it is present.

And you might want a third rule that is triggered by a change to the Resolution, to then also remove the "resolved-" label.

Then the next time the schedule rule ran, it would re-evaluate those changed issues.


Tags: cloud

jira-work-management-cloud