0

我想查找“开始日期”和“结束日期”之间的记录。我得到这个日期的记录,如“2013-05-22”、“2013-05-20”、“2013-05-10”、“2013-05-05”等。

我收集的字段如下:

array (
  '_id' => new MongoId("518221f16541b9980d000002"),
  'userId' => '2d40981c83a37e758ced05dc325e40fa',
  'kpiId' => 'f516ed1c59e6b310c47cdfc06abb17aa',
  'dateOpt' => 'customize',
  'startDate' => '2013-05-02',
  'endDate' => '2013-05-22',
  'personalTarget' => '',
  'assignedTarget' => '100000.00',
  'singleTargetAmt' => 6666.6666666667,
  'createdOn' => '2013-05-02 13:51:05',
  'updatedOn' => '2013-05-02 13:51:05',
  'distributionMethod' => 'manual',
) 

我的查询是:

  array(
    "kpiId" => 'f516ed1c59e6b310c47cdfc06abb17aa',
        "userId" => '2d40981c83a37e758ced05dc325e40fa',
        "startDate" => array
            (
                '$gte' => '2013-05-03'
            ),
    "endDate" => array
            (
                '$lte' => '2013-05-03'
            )      
    )

它没有提供任何记录。我的查询是错误的?

4

1 回答 1

0

尝试这样的事情

Query query = new Query(Criteria.elemMatch(
Criteria.where("startDate").lte(date)
.and("endDate").gte(date)
);
于 2013-05-02T13:08:32.560 回答