Find objects between two dates MongoDB

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

    use $gte and $lte to find between date data's in mongodb

    var tomorrowDate = moment(new Date()).add(1, 'days').format("YYYY-MM-DD");
    db.collection.find({"plannedDeliveryDate":{ $gte: new Date(tomorrowDate +"T00:00:00.000Z"),$lte: new Date(tomorrowDate + "T23:59:59.999Z")}})
    

提交回复
热议问题