Mongodb (v2.4.0) $match aggregate not working with date range

前端 未结 2 893
面向向阳花
面向向阳花 2021-01-14 08:46

I am using mongodb java driver thru maven repository (as below in pom.xml) to query transactions between date range with aggregate framwork. The java driver generates follo

2条回答
  •  我在风中等你
    2021-01-14 09:26

    I got it solved by removing the "" & $ prefix on the $date field of in $match. For you remove the same for $date, $gt & $lte

    So that it should look like

    db.transactions.aggregate(
    { "$match" : 
             { 
              'created_at': { 
                             $gt: "2001-04-12T12:00:00.000Z", 
                             $lt: "2020-04-13T12:00:00.000Z"
                            }
             }
    });
    

提交回复
热议问题