We are trying to compare two date/timestamp fields using the JQL/ advanced search

Esther Evangeline. V February 1, 2021

When we used the issuefunction in datecompare("", updated>created) this seems to be working in the jira server. When tried to replicate same in Jira cloud, the issuefunction is missing in the JQL. Is there a way to compare two custom Timestamp fields.

5 answers

3 accepted

2 votes
Answer accepted
Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 1, 2021

Hi Esther,

I can confirm that ScriptRunner for Jira Cloud provides the dateCompare() JQL function as documented here that can be used for searching against dates and the documentation page linked provides examples of how to use this query in Jira Cloud.

Also it is worth noting in Jira Cloud the enhanced search queries can only be run on the enhanced search page as documented here.

I hope this information helps.

Regards,

Kristian

Esther Evangeline. V February 2, 2021

Hi Kristian, 

Thanks for the understanding, Seems like we don't have the script runner in our Jira cloud and is there any way where I could some kind of date comparison logic for the JQL directly without having to add the script runner.

Regards,

Esther. V

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2021

You will need an app to provide a function like that.  Scriptrunner is the only one I know off the top of my head, but I've not looked for others (As an adaptavist, I tend to have SR on tap, so I haven't needed to look)

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 2, 2021

Hi Esther,

I can confirm you will need an App as Nic has said as this kind of query is not possible out of the box in Jira Cloud.

If you do not want to purchase the full ScriptRunner for Jira Cloud App then you can look at our Enhanced Search app which provides just the JQL functions.

I hope this helps.

Regards,

Kristian

Esther Evangeline. V February 3, 2021

Hi Kristian, 

Checked in the settings and found that the script runner is added to the system but somehow we are unable to find the issuefunction in (datecompare("","") functions and expressions in jira cloud. Any suggestion as to how I can get it working in the advanced search.

Thanks.

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 3, 2021

Hi Esther,

Can you please confirm are you running these on the Enhanced Search page inside your instance at the URL of <JiraCloudBaseURL>/plugins/servlet/ac/com.onresolve.jira.groovy.groovyrunner/jql-search-view as the JQL functions can only be run on the Enhanced Search Page in Jira cloud as described here.

You can then see details of how these filters can be used to power Agile boards or dashboards inside of the Knowledge Base Article located here.

Regards,

Kristian

Esther Evangeline. V February 3, 2021

Hi Kristian,

Should I have the enhanced search plugin also to run the query in the script runner enhanced page. Because tried to navigate to scriptRunner enhanced page but could not locate the same. and the above url that you provided is also not working. (<JiraCloudBaseURL>/plugins/servlet/ac/com.onresolve.jira.groovy.groovyrunner/jql-search-view). it is not loading

Thanks.

0 votes
Answer accepted
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 1, 2021

issuefunction is a function in Scriptrunner, have you installed that?

Neha Dua February 3, 2021

Yes script runner is installed  in JIRA however I and Esther found that "the date compare function in the middle of the expression is not natively supported by JIRA Cloud. "

mentioned in below link.

https://scriptrunner-docs.connect.adaptavist.com/jiracloud/enhanced-search.html#_troubleshooting_tips

 

Still unable to understand how we can use it as subquery as alternate solution provided in above link  . Can someone please assist on this.

0 votes
Answer accepted
Jack Brickey
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 1, 2021

JQL does not provide date compare capabilities. Maybe you could achieve your goal using automation. if this is a common need consider automation + custom field.

0 votes
Amir Katz (Outseer)
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.
January 19, 2023

To expand on a previous suggestion, here is how to do it with automation, without ScriptRunner:

  1. Create two new number fields, CreatedAsNum and UpdatedAsNum
  2. Add them to the issue screen(s), and move them to a new tab, call it Read-Only Fields
    1. This way users will usually not bother with them
    2. Not absolutely necessary, but it's helpful (for the Jira admin) to be able to see the fields
  3. Using automation and Smart Values, convert the value of Created from date/time to absolute time/seconds since the Epoch, and set the CreatedAsNum to this number
  4. Do the same for the Updated

Now you can use JQL to compare the two number fields.

An alternative option is to create a Smart Value that compares the fields (using the "compareTo()" function), set it to a new number field called 'CreatedVsUpdated' and then you can use it in the JQL. See here .

With both soultion you need to decide when to trigger the automation, and that depends on your needs.

The simplest triggering would be on an update of either of those two fields.

Caveat: I have not tested the above solutions.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 19, 2023

I'm afraid this is wrong.  JQL does not have any way to compare two fields.

You can indeed do it in an automation function, but that's not what the question was about.

0 votes
Daria Pavlova October 25, 2021

Hi, Esther!

Sorry for bothering you with the question but can you please give me an example of how  issueFunction in dateCompare("", updated>created) worked? I am trying to use this but get the error:
Error in the JQL Query: Expecting ')' or ',' but got '>'. (line 1, character 67)

I mean the whole JQL line as an example so I can repeat with my data. 

Thank you! 

Juan Francisco Sacristan Garcia November 19, 2021

 issueFunction in dateCompare("", "updated>created")

Bryan November 22, 2021

You will get answers faster if you DON'T ask questions an an answer. Make a new question and you will get answers that way.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
TAGS
AUG Leaders

Atlassian Community Events