$gte for big number


Why doesn’t my query work ?
Is it because the number is very large ?

(When I click on “Find” the result is not displayed, so I show you the display before clicking on “Find”)
(Too complicated to manage the time zone in MongoDb, so I’m trying to search dates by Ticks)


Hi @Imran_Sheikh1,

MongoDB saves dates in UTC, so managing time zones should not be complicated if you work with dates.

That being said, looks like you are not saving Ticks property as Number in the database. Can you double-check that? That can be the reason why your query does not work.

Hi @Imran_Sheikh1

Use {_id: {$gte: NumberLong('638498107935187178')}} in Compass

Basically the same reason as https://www.mongodb.com/community/forums/t/issue-with-int64-stored-in-the-field-id/277905/2?u=chris

1 Like

Thank you for your reply.

When I enter a delivery date for January 27, 2024, mongodb stores the date January 26, 2024 23:00.

This is problematic if I want to have all deliveries on January 27, 2024.

Even if Ticks doesn’t have a quotation mark, isn’t it automatically a number?
I’ll try to store it correctly.

I finally figured out how to store the local date in MongoDb in C#.

Otherwise my adventure with MongoDb would have stopped before it even started :frowning_face: :cry:.