Searching between dates using OData

Azure Search uses OData expressions syntax to build filter queries when searching within a searchable section of data.

Searching within a data range indicates that you should use a DateTimeOffSet, which is the data type stored in the, but it is easier to search using the following format


To search between two dates, the filter list needs to be in the following format

$filter=year ge 2016-01-01T00:00:00-00:00 and year le 2016-12-31T23:59:59-00:00

If you are passing this via the REST API, URL encode the string before passing it to the service.
If you are using the .NET Azure package from NUGET, create a new Search Parameters object and pass the string to the Filter parameter and the encoding will happen automatically.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s