Uploaded image for project: 'Python Driver'
  1. Python Driver
  2. PYTHON-1712

Operator $date does not seem to be working

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 3.6.1
    • Component/s: Query Operations
    • Labels:
      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
       

            Assignee:
            bernie@mongodb.com Bernie Hackett
            Reporter:
            hmducoulombier@marketing1by1.com Henri-Maxime Ducoulombier
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: