mongodb日期范围_在Java中使用MongoDB中的日期范围查询

我是使用MongoDB的新手。我有它充满了收据,例如:一个收据看起来是这样的:在Java中使用MongoDB中的日期范围查询

{

"_id" : {

"$oid" : "510fa057c6f818c2bfd0b279"

} ,

"StoreName" : "Metro" ,

"StoreNumber" : 521 ,

"Items" : [ {

"ItemName" : "Battery" ,

"ItemManufacturer" : "Duracell" ,

"ItemPrice" : 12 ,

"ItemQuantity" : 2 ,

"ItemTotalPrice" : 24

} ,

{

"ItemName" : "TV CRT 25 inch" ,

"ItemManufacturer" : "Toshiba" ,

"ItemPrice" : 1659 ,

"ItemQuantity" : 1 ,

"ItemTotalPrice" : 1659

} ,

{

"ItemName" : "Mobile" ,

"ItemManufacturer" : "Nokia" ,

"ItemPrice" : 2966 ,

"ItemQuantity" : 4 ,

"ItemTotalPrice" : 11864

}

] ,

"Date" : {

"$date" : "2012-06-16T01:21:11.758Z"

} ,

"Total" : 13547

}

我需要查询,我指定日期范围以获得在该范围内的所有收据。我试过以下查询,但它什么都没有返回。

BasicDBObject query =

new BasicDBObject(

"Date",

new BasicDBObject(

"$gt",

"2012-06-20T10:05:21.968Z"

).append(

"$lte",

"2012-09-24T05:29:43.031Z"

)

);

你可能感兴趣的:(mongodb日期范围)