Skip to content
This repository has been archived by the owner on Feb 25, 2018. It is now read-only.

Problems running query comparing to createdAt date #12

Closed
ldjpr opened this issue Apr 27, 2012 · 1 comment
Closed

Problems running query comparing to createdAt date #12

ldjpr opened this issue Apr 27, 2012 · 1 comment

Comments

@ldjpr
Copy link

ldjpr commented Apr 27, 2012

I am trying a query composed of a geo point and comparing date but the results seems that it is ignoring the date part of the where. Is it correct the way the query is performed?

Could you provide some samples comparing against dates using query contraints like: $gte, $in, etc.

Here my code snippet:

$params = array(
'className' => 'xx',
'query' => array(
'geo' => array(
'$nearSphere' => array(
'__type'=> 'GeoPoint', 'latitude' => 25.727409, 'longitude' => -80.306389),
'$maxDistanceInKilometers' => 1)),
//where
'createdAt'=> array(
'$gte' => '2012-04-24T01:02:52.249Z'),
'order' => 'bizName',
'limit' => 10);
$request = $parse->query($params);

Thanks

@ldjpr
Copy link
Author

ldjpr commented Apr 29, 2012

I have found the error. The right way to query against a date is:

$params = array(
'className' => 'xxx',
'query' => array(
'geo' => array(
'$nearSphere' => array(
'__type'=> 'GeoPoint', 'latitude' => 25.727409, 'longitude' => -80.306389),
'$maxDistanceInKilometers' => 1),
'createdAt'=> array(
'$gte' => array('__type' => 'Date', 'iso' => '2012-04-28T00:00:00.0000'))),
'order' => 'bizName',
'limit' => 10);

In case this can help someone.

Les

@ldjpr ldjpr closed this as completed Apr 29, 2012
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant