Possible bug when filtering on date?

Hi Intercom team,

I’ve been a bit puzzled by the behavior of the API when filtering on date and I’m pretty sure there is a bug with the API. This matches what edwin_sosa reported here.

I am trying to pull contacts using the search API, iterating day by day over updated_at (or created_at, which has the same issue).

If I pull by intervals of under 24 hours, I get zero results. But if I pull interval over 24 hours, I do:

Timeframe: 08-23 to 08-25 (PST)
Returns: 31 records
{"query":{"operator":"AND","value":[{"field":"updated_at","operator":">","value":1598165999},{"field":"updated_at","operator":"<","value":1598338799}]},"sort":{"field":"updated_at","order":"ascending"},"pagination":{"per_page":150}}

First record returned: updated_at: 2020-08-24T08:18:05.000Z
(while the interval above starts at 2020-08-23T06:59:59.000Z)

08-23 to 08-24
Returns: 0 records
{"query":{"operator":"AND","value":[{"field":"updated_at","operator":">","value":1598165999},{"field":"updated_at","operator":"<","value":1598252399}]},"sort":{"field":"updated_at","order":"ascending"},"pagination":{"per_page":150}}

08-24 to 08-25
Returns: 0 records
{"query":{"operator":"AND","value":[{"field":"updated_at","operator":">","value":1598252399},{"field":"updated_at","operator":"<","value":1598338799}]},"sort":{"field":"updated_at","order":"ascending"},"pagination":{"per_page":150}}

Digging further, it seems that the > operator is jumping 24 hours.
If the query asks for updated_at > 2020-08-23T07:00:00.000Z, it looks like the API returns only records where updated_at > 2020-08-24T07:00:00.000Z, which would explain why my interval of 24 hours return nothing.

I’m doing a workaround by subtracting 24 hour to my lower bound, but that is not how I would expect that API to behave.

Hey @PaulCothenet :wave:

Thanks for flagging this one - it’s something we’re aware of as unexpected and unwanted behaviour but are blocked on fixing currently. Not on our agenda to address in the short term for this reason but there’s room in the long term for us to get this fixed.

For now, l would suggest using your workaround. We’ll update the docs to match current behaviour to avoid any further confusion. Cheers!

Hi @zach. Good to know. The workaround works for us now!