Compare 2 dates in mongo find method

前端 未结 4 1762
一向
一向 2021-01-03 09:57

I have mongo documents containing a last_active date and a created date. I would like to search for all documents where the day of last_active is not equal

4条回答
  •  死守一世寂寞
    2021-01-03 10:41

    You can use a function within your query:

    db.mycollection.find({
      $where: function() {
        return this.created.getDate() !== this.last_active.getDate();
      }
    })
    

提交回复
热议问题