Query by date with the REST API

This page shows multiple ways to query documents based on a date field.

Here we use a few predicates that can query based on Date or Timestamp fields. Feel free to explore the Date & Time based Predicate Reference page to learn more about this.

Query a Date Field by an exact date

This example shows how to query for all the articles with the release-date field (Date) equal to January 22, 2017. Note that this only works for the Date Field, not the Time Stamp field.

Here are all the required parameters for this query:

all of type "article"

q=[[at(document.type,"article")]]

match the required date

q=[[at(my.article.release-date, "2017-01-22")]]

Query a Date Field that falls in a certain month & year

This is an example of a query for all documents of the type "blog-post" whose release-date is in the month of July in the year 2017. This might be useful for a blog archive.

Here are the required parameters for this query:

of the type "blog-post"

q=[[at(document.type,"blog-post")]]

in a certain month

q=[[date.month(my.blog-post.release-date, "July")]]

in a certain year

q=[[date.year(my.blog-post.release-date, 2017)]]

Query by Publication Dates

You can also query document by their publications dates.

This is an example of a query for all documents of the type "blog-post" whose original publication date is in the month of May in the year 2016.

Here are the required parameters for this query:

all of type "blog-post"

q=[[at(document.type, "blog-post")]]

published in May

q=[[date.month(document.last_publication_date, "May")]]

published in 2016

q=[[date.year(document.last_publication_date, 2016)]]