JQL on search with updated date time does not work correctly

I am trying to poll issues using the /search endpoint but it does not yield correct results and I believe it is not honoring the DT stamps that I am passing in my request.
Take a look at postman screenshot, the condition is updated > ‘2022-05-20 09:41’.
But in response, we also got older records with updated date “updated”: “2022-05-20T08:45:33.109+0000”.
Am I doing something wrong here?

Maybe it’s related to your timezone. The Updated field is returned as UTC (+0000) Timezone and depending on your timezone you may add/substract a few hours.

1 Like

Welcome to the Atlassian Developer Community, @SamratDutta !

At first glance, your JQL looks correct. I also tried it on my instance and it works as expected (see images below).

First call: jql=updated > '2022-04-13 15:29'

Bumping the time +1 minute: jql=updated > '2022-04-13 15:30'

That said, I am unsure what caused the difference in our runs. The only thing I can think of is the timezone you are in when running your Postman request. What timezone are you in?

Cheers,
Ian

EDIT:

To verify the timezone hypothesis, I changed my instance’s timezone to 5 hours earlier (from +8 to +3) and I was able to arrive to a similar scenario you hit.

Thanks for the detailed message Ian!

Can you provide more info on how time zone plays out here with JQL?

If this is my query jql=updated > '2022-04-13 15:29', regardless of the time zone, Jira should internally account the time zone and return the records accordingly right?

I don’t suppose you expect end user to do a filtering on top of records returned by the above API.

The use case is, I would like to poll this endpoint every 5 mins.
In each poll, the updated date in JQL query will be 5 mins ahead of previous call.

Thanks

Hi @ISSandboxes , welcome to the developer community!

For your use case, if you intend to poll the issues (in 5-minute intervals) that were updated in the last x minutes, would the use of period formats relative to the current time/now work for you? For example if you want to search issue that were updated in the last 5 minutes, then you can use the jql updated > -5m; this also works for weeks (w), days (d), and hours (h), see this page for more information.

If there is an option to not use polling, you might want to check webhooks. This way, you need not call the endpoint if there were no issue updates in the last x interval.

Hope this helps.

Ian

Hi @iragudo

Sadly, Webhooks is not an option for us right now.

We want to use polling and we can’t use period formats as our poll interval will not happen exactly 5 mins later every time. At times, there may be a delay (say 7 mins later) due to some system latency or some other reason. But we don’t want to miss the events when there’s a delay.

Let’s say the interval is 5 mins but there was delay of 3 mins and if we use periodic date -5m, we will end up missing issues that got updated in the first 3 mins as the poll happened after 8 mins after last poll.

For us, querying by date-time is more accurate and our platform is built to poll by date time.

Anyhow, please find time to answer the original question.

Can you provide more info on how time zone plays out here with JQL?
If this is my query jql=updated > '2022-04-13 15:29' , regardless of the time zone, Jira should internally account the time zone and return the records accordingly right?
I don’t suppose you expect end user to do a filtering on top of records returned by the above API.

Thanks

Hi @ISSandboxes ,

Yes, the timezone is taken into consideration and the records were returned accordingly.

I’ll try to breakdown my previous example:

  1. I am calling Search API with JQL endpoint from a GMT+8 location
  2. I changed my Jira Cloud instance settings to GMT+3
  3. I called the REST API with this JQL jql=updated > '2022-04-13 15:29' (implied GMT+8)
  4. The response returned
"fields": {
    "updated": "2022-04-13T10:29:34.084+0300"
}

At first glance, it looks incorrect because 2022-04-13 10:29:34 is not greater than 2022-04-13 15:29 but if we consider the timezone (see table below) then we see that the returned issues satisfy my JQL.

Raw Date UTC Date
2022-04-13 10:29:34 GMT+3 2022-04-13 07:29:34
2022-04-13 15:29:00 GMT+8 2022-04-13 07:29:00

I hope this answers your question.

In your scenario, updated > 2022-05-20 09:41 is from what timezone? Based on your screenshot, your Jira cloud instance is in UTC, so if the REST API caller is not from the same timezone, kindly convert 09:41 to UTC and compare. To identify the API caller’s timezone (in your case from Postman), you can call /rest/api/2/myself.

Cheers,
Ian