Find objects between two dates MongoDB

后端 未结 14 2044
余生分开走
余生分开走 2020-11-21 06:03

I\'ve been playing around storing tweets inside mongodb, each object looks like this:

{
\"_id\" : ObjectId(\"4c02c58de500fe1be1000005\"),
\"contributors\" :          


        
14条回答
  •  有刺的猬
    2020-11-21 06:14

    db.collection.find({$and:
      [
        {date_time:{$gt:ISODate("2020-06-01T00:00:00.000Z")}},
         {date_time:{$lt:ISODate("2020-06-30T00:00:00.000Z")}}
       ]
     })
    
    ##In case you are making the query directly from your application ##
    
    db.collection.find({$and:
       [
         {date_time:{$gt:"2020-06-01T00:00:00.000Z"}},
         {date_time:{$lt:"2020-06-30T00:00:00.000Z"}}
      ]
    
     })
    

提交回复
热议问题