Jira Automation - How to compare two dates

Jayson2 Contreras December 6, 2024

Hi everyone,

Good day!

I'm trying to create an automation rule wherein the custom field "SLA Overdue" will automatically be filled out using scheduled trigger. However, I cannot find the correct way to compare two dates. Basically, the rule will have to be based on priority and the number of days since the issue was created.

The conditions are as follows:

 

Condition 1: Low Priority (It must be resolved within 10 days)

If issuetype = defect and status != closed and priority = low and the date today is greater than issue.created.plusBusinessDays(9)

then set the value of SLA Overdue to "Yes"

 

 

Condition 2: Medium Priority (It must be resolved within 5 days)

Else If issuetype = defect and status != closed and priority = medium and the date today is greater than issue.created.plusBusinessDays(4)

then set the value of SLA Overdue to "Yes"

 

 

Condition 3: High Priority (It must be resolved within 2 days)

Else If issuetype = defect and status != closed and priority = high and the date today is greater than issue.created.plusBusinessDays(1)

then set the value of SLA Overdue to "Yes"

 

 

Condition 4: Critical Priority (It must be resolved within a day)

Else If issuetype = defect and status != closed and priority = medium and the date today is greater != issue.created

then set the value of SLA Overdue to "Yes"

 

Else set the SLA Overdue to "No"

 

These are some of the methods I tried to compare the current date and the date created:Screenshot 2024-12-06 160649.pngScreenshot 2024-12-06 160623.png

Note: I'm trying to use the format date function to only compare the date (dd/MM/yyyy) and not the time (h:mm).

2 answers

1 accepted

0 votes
Answer accepted
Bill Sheboy
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 Leaders.
December 6, 2024

Hi @Jayson2 Contreras 

For a question like this, context is important for the community to help.  Please post the following:

  • what type of project is this (e.g., company-managed, team-managed, etc.), 
  • an image of your complete automation rule,
  • images of any relevant actions / conditions / branches,
  • an image of the audit log details showing the rule execution, and
  • explain what is not working as expected.

 

Until we see those...

You are formatting dates for comparisons as "dd/MM/yyyy".  That will not work as you expect because the values are text (when date formatting is used) and so a value such as "31/12/2023" will be greater than "01/01/2024" with a text comparison: the days are the first, left-to-right.

When comparing dates this way, use the jiraDate format as that is "yyyy-MM-dd", such as:

{{now.jiraDate}}

 

Kind regards,
Bill

Jayson2 Contreras December 8, 2024

Hi @Bill Sheboy

 

Thank you for your answer. I was able to make my automation rule worked by comparing the dates using jiraDate format.

This is my automation rule that worked:

1.png2.png

 

Regards,

Jayson

Bill Sheboy
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 Leaders.
December 9, 2024

Awesome; I am glad to learn it is working!  Please consider marking this question as "answered" to help others with a similar need find solutions faster.  Thanks!

Like Jayson2 Contreras likes this
1 vote
Marc - Devoteam
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 Leaders.
December 6, 2024

Hi @Jayson2 Contreras 

The plusBusinessaction is to add and the store the information , then you can compare.

Suggestion:

  1. In the condition user {{now.diff(issue.created).days}} and compare agains the number of days.

    Like, is bigger/smaller then 9

  2. Create 4 variables, 1 for each compare action.

    Create the variables based on the second value in the conditions and the replace the second value in the conditions by the variable.
Jayson2 Contreras December 8, 2024

Hi @Marc - Devoteam

Good day!

Thanks for your answer. I have tried it using the lookup table but still didn't work. I have tried comparing the dates using jiraDate format as suggested by @Bill Sheboy and it worked.

 

Regards,

Jayson

Like Marc - Devoteam likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events