Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering dates between x & y using ODATA

I'm looking into the new ASP.NET Web API as a reporting tool.

In SQL I would do this:

WHERE order_date 
    BETWEEN to_date ('2003/01/01', 'yyyy/mm/dd') 
    AND to_date ('2003/12/31', 'yyyy/mm/dd');

...how do these type of command translate in the ODATA protocol URL?

like image 368
Paul Brown Avatar asked Dec 07 '22 13:12

Paul Brown


1 Answers

With the Visual Studio 2012.2 update, OData support is back and the following url works for filtering dates:

http://host/api/controller?$filter=order_date+gt+datetime'2003-01-01'+and+order_date+lt+datetime'2003-12-31'

If you want to include a time, you should specify the dates in ISO 8601 format.

like image 149
mhu Avatar answered Dec 19 '22 19:12

mhu