Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

issueFunction in dateCompare example

Daria Pavlova October 25, 2021

Dear community!

 

Here I am again searching for a help.

I am trying to use issueFunction in dateCompare in my JQL request and I am repeatedly getting errors instead of what I want. 

For example I try to find issues that had not been commented within one week of creation:

project = Operations AND issueFunction in dateCompare("created +1w < firstCommented")

and I get:

Scripted function "dateCompare" compilation failure. Contact administrator and check logs. Message: The comparison must contain exactly one comparison operator which is either >, <, =, <= or >=.

Can someone give me a whole line of successful JQL request so I can repeat it with my own data?

Just cannot get how it works. Please help. Thank you! 
 

1 answer

2 votes
Tessa Tuteleers
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 25, 2021

Hi @Daria Pavlova ,

you forgot something in your syntax.

The JQL query works as follows:

dateCompare(Subquery, date comparison expression)

You added the subquery in front of the issuefunction, and jumped right to the date comparison.

You can do what you want in 2 ways:

  • keep your project conditon in front and use an empty subquery (better)
    project = Operations AND issueFunction in dateCompare("", "created +1w < firstCommented")
  • add your condition as subquery (less performant)
     issueFunction in dateCompare("project = Operations", "created +1w < firstCommented")

Hope this helps!

  • Tessa
Steve Letch
Contributor
January 20, 2022

I'm having a bit of trouble with the formatting when you try and put things with two words in the subquery

 

issueFunction in dateCompare("Issuetype = Planned Change AND created >= startOfYear()", "Scheduled End < Scheduled Start")

 

Error in the JQL Query: Expecting either 'OR' or 'AND' but got 'Change'. (line 1, character 21)

Tessa Tuteleers
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 24, 2022

Hi @Steve Letch,

if you want to use multi word strings, you always need to quote them, if you are already using double quotes as you are now, you can use single quotes within them. 

This would look like that for you: 

 issueFunction in dateCompare("Issuetype = 'Planned Change' AND created >= startOfYear()", "'Scheduled End' < 'Scheduled Start' ")

Could you confirm this works for you? 

Cheers,
Tessa

Steve Letch
Contributor
January 26, 2022

Been off sick a couple days but will check tomorrow, thanks

Constance Hua
Contributor
February 2, 2023

Hi Tessa, 

unfortunately this does not work either: 

  • JQL:  issueFunction in dateCompare("", "'Period End' > 'Period Start'+1M ")
  • Error: Scripted function "dateCompare" compilation failure. Contact administrator and check logs. Message: Field name: 'Period End' not found or not a date or datetime.

It seems that this function is not well configured because it does not work with fields which have spaces in the name. 

I also tried with cf[1234] and other date fields on the system but no luck. 

Constance Hua
Contributor
February 3, 2023

Hi all, I contacted the support and here is the answer for future reference: 

"I believe you don't need to add a single quotation for the custom field when using the dateCompare() JQL function."

issueFunction in dateCompare("", "end date > start date+1M")
Like Stefano Vidonis likes this
Tobias Steinhäusler
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 11, 2024

Hi, I am having the same issue as above. I am using this JQL:
issueFunction in dateCompare("", "Target end+1w > Epic Committed Target end")

The JQL runs successfully, however it seems to ignore the "+1w" calculation.

When I run the query WITHOUT the "+1" it returns all issues where the "Target end" is bigger that the "Epic Committed Target End" date as expected issueFunction in dateCompare("", "Target end > Epic Committed Target end"), 

However when I add the "+1w" clause it returns ALL Epics also where the dates are different...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events