JQL to show issues where status changed from one to another within the last hour

Joel Lepp January 13, 2020

I'm trying to write a query that will return all of the tickets where the status changed FROM 'StatusA' TO 'StatusB' DURING (current date/time -1h, current date/time).

At first I was hoping that the now() function would work, but it appears that arguments cannot be passed to it.

Trying to make this dynamic so that I don't have to update the query every hour -- because that just isn't realistic.

 

Any thoughts?

2 answers

1 accepted

8 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.
January 13, 2020

you can use this JQL or similar.

updated >= "-2h" and updated <= "-1h"

Joel Lepp January 13, 2020

Except I don't believe that would link directly to the status change from A to B.
That would flag any issues that have been updated between that hour/time difference that have ever moved from A to B (regardless of when).

Example:
Issue changes from A to B on 12/15/2019
Today is 1/13/2020 and someone makes some sort of update to the ticket within the last hour.
I would expect that the issue would now appear in the filter I am trying to set up -- in this scenario I wouldn't want it to.

This is where status changed from (A) to (B) during (date1, date2) works nice for date ranges. Doesn't work for trying to reference the last hour.

Like Averil Stewart likes this
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.
January 13, 2020

I think you can accomplish your goal but you need to tweak it a bit to meet your needs. Here is an example....

status changed FROM "to do" to "done" after "-2h" and status changed FROM "to do" to "done" before "-1h"

LMK...

Like # people like this
Joel Lepp January 13, 2020

Aha!

So, after reading your most-recent reply, I've figured out what I needed to do.

Like I said in the beginning, I was trying to pass arguments to the now() function - which I knew didn't work.

From my example I originally provided, I've only ever passed dates after during in my query ex: during (date1, date2)

 

So, in the end...

What I was trying to do (which DOES NOT work):
status changed from (A) to (B) during (now(-1h), now())

What I needed to do (which DOES work):
status changed from (A) to (B) during (-1h, now())

 

Typically my queries consist of a lot of date changes, so I use startOfDay(), endOfDay() quite a bit and pass day change arguments to those (ex: -1d)

I never thought to just pass a hour change not inside of an actual function.

 

Thanks for providing an example that guided me to what I really wanted.

Like # people like this
Anton_Ermolaev January 16, 2020

I think "now()" in this case is redundant. A simpler request will be

status changed from (A) to (B) after -1h

is it correct?

Like # people like this
Joel Lepp January 16, 2020

That makes sense. Like I think I said somewhere in my reply in this chain, my filters typically deal with dates and have always been a date range - that's why my mind went to the DURING approach I guess.

You are correct though. Using after -1h would achieve the same thing. Thanks for pointing it out as another solution.

Like # people like this
Paul Vitic November 23, 2020

My query 

 

status changed to Closed during ("2020-10-01", "2020-11-01")

 

is not yielding any results although there are tickets that had this status transition.

 

Can anyone help?

Like # people like this
AlanC_aceik June 8, 2021

Is your project a "Next Gen" aka "Team Managed" project?

There is a bug in Next Gen that leads to inconsistent results when you query on the name of a status (particularly when the name is used in multiple projects, e.g. one of the default status names).

The workaround is to change the name of the status to something unique or don't use the name at all, but instead use the ID of the status in question.

See https://jira.atlassian.com/browse/JSWCLOUD-21154

and also Stephen Wright's comment on the status ID workaround: https://community.atlassian.com/t5/Jira-Software-questions/BUG-JQL-Unable-to-query-next-gen-project-s-issues-with-status/qaq-p/1319216#M67818

Jimmy Seddon
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 24, 2022

Thank you guys!  This thread was super helpful in helping me solve a question for one of my users!

Like Filipi Lima likes this
Menna Khaled June 8, 2022

is there a similar thing for seconds? trying to resolve an issue with missing jira trigger 'status changed' trigger. So was aiming at using the 'issue updated' trigger along with a JQL which says the status changed VERY recently. Because else any other update will also trigger the workflow.

I found there is -1m, but is there a thing for seconds?

Sebastian Schult July 7, 2022
Updated

Search for issues that were last updated on, before, or after a particular date (or date range). Note that if a time-component is not specified, midnight will be assumed. Please note that the search results will be relative to your configured time zone (which is by default the Jira server's time zone).

Use one of the following formats:

"yyyy/MM/dd HH:mm"
"yyyy-MM-dd HH:mm"
"yyyy/MM/dd"
"yyyy-MM-dd"

From: https://support.atlassian.com/jira-software-cloud/docs/advanced-search-reference-jql-fields/

No seconds by Design.

FYI if you have API data, yes seconds are there:

{
  "issues": [
    {
    "fields": {
      "updated": "2002-04-06T12:12:56.000+0900",
    },
  "id": "1",
  "key": "abc-1",
  },
  ]
}

Paul Vitic July 8, 2022

The projects are next gen but I am afraid using status ids also does not work

 

status changed to 6 after -1m

 

where 6 is id of Closed

 

still returns empty result

Mauricio Heberle
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.
November 25, 2022

@Joel Lepp thank you so much!

Like Joel Lepp likes this
0 votes
Geeta Basker December 28, 2022

I would use this -

status changed from "In Progress" to Done DURING (now(-1), now())

Suggest an answer

Log in or Sign up to answer