php - mongo db date range query (between date range) -


i want find records between "startdate" & "enddate". record date "2013-05-22", "2013-05-20","2013-05-10","2013-05-05" etc.

my fields in collection below :

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', )  

and query :

  array(     "kpiid" => 'f516ed1c59e6b310c47cdfc06abb17aa',         "userid" => '2d40981c83a37e758ced05dc325e40fa',         "startdate" => array             (                 '$gte' => '2013-05-03'             ),     "enddate" => array             (                 '$lte' => '2013-05-03'             )           ) 

it gives no records. query wrong ?

try this

query query = new query(criteria.elemmatch( criteria.where("startdate").lte(date) .and("enddate").gte(date) ); 

Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -