Find objects between two dates MongoDB

后端 未结 14 2107
余生分开走
余生分开走 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:18

    Use this code to find the record between two dates using $gte and $lt:

    db.CollectionName.find({"whenCreated": {
        '$gte': ISODate("2018-03-06T13:10:40.294Z"),
        '$lt': ISODate("2018-05-06T13:10:40.294Z")
    }});
    

提交回复
热议问题