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

Operator $date does not seem to be working

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor - P4
    • Resolution: Community Answered
    • Affects Version/s: 3.6.1
    • Fix Version/s: None
    • Component/s: Query Operations
    • Labels:
      None

      Description

      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
       

        Attachments

          Activity

            People

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

              Dates

              Created:
              Updated:
              Resolved: