Compare two date fields in MongoDB

前端 未结 6 1334
别跟我提以往
别跟我提以往 2020-12-10 04:36

in my collection each document has 2 dates, modified and sync. I would like to find those which modified > sync, or sync does not exist.

I tried

{\'m         


        
6条回答
  •  感动是毒
    2020-12-10 05:36

    Use Javascript, use foreach And convert Date To toDateString()

    db.ledgers.find({}).forEach(function(item){
    
        if(item.fromdate.toDateString() == item.todate.toDateString())
        {
            printjson(item)
        }
    })
    

提交回复
热议问题