I’m guessing that Shopify stores the date in milliseconds but doesn’t provide that precision in the Order object from an orders query. I would prefer to (optionally) see the full precision in the Order object.
What I’m working on here is a polling strategy for new and updated orders. (Yes, I know about webhooks and may use them in the future.) The polling issue is that since Shopify doesn’t send milliseconds in the updatedAt value, to avoid missing any updates, my next poll has to start with the same second as the last update in the previous poll, meaning that I’ll have to re-process some orders.
Does anyone know how the milliseconds are rounded in the Order object? If that is predictable, then I could rely on it to avoid reprocessing.
E.g. if .499 is always rounded down and .500 is always rounded up, then my query could be :>= seconds.500.
Hey @Mitchell_Claborn, I looked in to this and the behaviour you are seeing is expected.
There isn’t rounding happening, but moreso if you’re requesting everything after 2025-03-13T16:04:28 the time used will be 2025-03-13T16:04:28.000. The reason for this is to ensure all orders within the same second are captured.
The easiest solution since you are using a range is to use a specific date for :< so you know where to start with your next query, instead of relying on the timestamp of the last returned order.
I did some testing and looked in to our logs, and “now” appears to resolve to microsecond precision.
For your polling strategy, using specific timestamps instead of “now” is definitely the better approach. Since “now” gives you unpredictable microsecond precision, your workaround of tracking the exact updatedAt timestamp of your last processed order and adding .999Z milliseconds gives you consistent, repeatable boundaries between polling cycles. This eliminates any uncertainty about which orders were already processed.