-
Type: Bug
-
Resolution: Done
-
Priority: Minor - P4
-
None
-
Affects Version/s: 3.6.1
-
Component/s: Query Operations
-
None
Querying the database with the $date operator (to convert a string or integer timestamp) does not work and returns 0 results.
Step to reproduce :
from pymongo import MongoClient client = MongoClient(host='localhost', port=27001) db = client['test'] db.contact.count() # OK, returns 1000 on my test collection db.contact.find({"datefield":{"$gt":{"$date": "2000-01-01T00:00:00Z"}}}).count() # KO, returns 0 (even if it is > 0) db.contact.find({"datefield":{"$gt":{"$date": 0}}}).count() # KO, returns 0 (even if it is > 0)
Note: I didn't test on 3.7+.
Note 2 : this query works in the shell
Note 3 : this method for querying dates is not very well documented, and I don't know if it works with other drivers too