Querying records in a date range

From DreamFactory
Jump to: navigation, search
DreamFactoryTutorialsQuerying records in a date range
Line 22: Line 22:
  
 
* Table name: contact
 
* Table name: contact
* Filter parameter in API call: <pre>contacted_date >= 2015-10-01 AND contacted_date <= 2015-10-31</pre>
+
* Filter parameter in API call: <pre>(contacted_date >= 2015-10-01) AND (contacted_date <= 2015-10-31)</pre>
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?filter=contacted_date%20%3E%3D%202015-10-01%20AND%20contacted_date%20%3C%3D%202015-10-31</pre>
+
* Request URL: <pre>https://foo.com/api/v2/db/_table/contact?filter=(contacted_date%20%3E%3D%202015-10-01)%20AND%20(contacted_date%20%3C%3D%202015-10-31)</pre>

Revision as of 14:47, 8 January 2016

      1. Tutorial

GET records in a SQL or NoSQL database within a date range using a filter string. Try these examples in the 'API Docs' tab of the DreamFactory Admin Console or from the command line with cURL.

Note that filter strings are simply SQL queries with ordinary SQL operators, including <, <=, >, >=, =, etc.

      1. API Endpoint
GET https://{url}/api/v2/{api_name}/_table/{table_name}?filter={filter_string}
      1. API Docs Screenshot

Swagger-date-filter.png

      1. Example - GET contact records with contacted_date equal to October 1, 2015
  • Table name: contact
  • Filter parameter in API call:
    contacted_date = 2015-10-01
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?filter=contacted_date%20%3D%202015-10-01
      1. Example - GET contact records with contacted_date in the month of October, 2015
  • Table name: contact
  • Filter parameter in API call:
    (contacted_date >= 2015-10-01) AND (contacted_date <= 2015-10-31)
  • Request URL:
    https://foo.com/api/v2/db/_table/contact?filter=(contacted_date%20%3E%3D%202015-10-01)%20AND%20(contacted_date%20%3C%3D%202015-10-31)