On Date Value

Date queries

All of the comparison operators can be used to work with the value type of date.

Examples in this section are based on data in the following sample collection:

taskNametimepriority
stringdatestring
Debug soft2014-11-12 19:00:00.000High
Use cool API2014-11-10 20:00:00.000Low
Create an app2014-11-09 09:00:00.000High

Examples

Retrieve all the objects that equal the specific date value:
curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"where":{ "time":"2014-11-12 19:00:00.000"}}' \
  https://api.appery.io/1/db/collections/todo/query
To get all the objects that contain a date greater than a certain value, use the $gt operator. This will retrieve all objects that contain dates greater (later) than the 10th of November 2014:

curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"where":{ "time" : {"$gt" :"2014-11-10 00:00:00.000"}}}' \
  https://api.appery.io/1/db/collections/todo/query
To get all the objects with dates less than a certain value, use the $lt operator. This will retrieve all objects with dates less than (earlier) the 10th of November 2014:
curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"where":{ "time" : {"$lt" :"2014-11-10 00:00:00.000"}}}' \
  https://api.appery.io/1/db/collections/todo/query
It’s also possible to retrieve dates in a certain range. Use a combination of the $lt and $gt operators. This will retrieve all objects with dates between the 9th and 11th of November 2014:
curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"where":{"time": {"$gt":"2014-11-09 00:00:00.000", "$lt" :"2014-11-11 00:00:00.000"}}}' \
  https://api.appery.io/1/db/collections/todo/query
Accessing _createdAt and _updatedAt columns

You need to use a different syntax to access the predefined columns _createdAt and _updatedAt via a REST service. The date value must be presented like the following:

{ "time" : "2014-11-04T15:25:19.437Z" }
Also, the where clause must contain the $date variable and look like the following:

curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"where":{"_createdAt":{"$date":"2014-11-04T15:25:19.437Z"}}}' \
  https://api.appery.io/1/db/collections/todo/query
The _updatedAt column can be accessed the same way:

curl -X POST \
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" \
  -H "Content-Type: application/json" \
  -d '{"where":{"_updatedAt":{"$date":"2014-11-07T15:48:20.518Z"}}}' \
  https://api.appery.io/1/db/collections/todo/query