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:

taskName

time

priority

string

date

string

Debug soft

2014-11-12 19:00:00.000

High

Use cool API

2014-11-10 20:00:00.000

Low

Create an app

2014-11-09 09:00:00.000

High

Examples

Retrieve all the objects that equal the specific date value:
curl -X GET 
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" 
  -d 'where={ "time":"2014-11-12 19:00:00.000"}' 
  https://api.appery.io/1/db/collections/todo
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 GET 
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" 
  -d 'where={ "time" : {"$gt" :"2014-11-10 00:00:00.000"} }' 
  https://api.appery.io/1/db/collections/todo
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 GET 
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" 
  -d 'where={ "time" : {"$lt" :"2014-11-10 00:00:00.000"} }' 
  https://api.appery.io/1/db/collections/todo
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 GET 
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" 
  -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
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 GET 
  -H "X-Appery-Database-Id: 544a5cdfe4b03d005b6233b9" 
  -d 'where={"_createdAt":{"$date":"2014-11-04T15:25:19.437Z"}}' 
  https://api.appery.io/1/db/collections/todo
The _updatedAt column can be accessed the same way:

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