WCF Data Services conveniently allow querying and filtering data via options in the URL. For example, say I want Products with a price greater than 20:
http://www.example.com/Service.svc/Products?$filter=Price gt 20
But how do I use the $filter
option with a DateTime
? Say I want all Products that have been modified this month.
http://www.example.com/Service.svc/Products?$filter=ModifiedDate gt '2012-05-02'
This doesn't work for me; it gives the error message
Operator 'gt' incompatible with operand types 'System.DateTime' and 'System.String' at position 13.
I get the same with other comparison operators (ge, lt, le, eq). What is going on? How do I make this work? Do I need a certain DateTime format? What I tried above seems to be documented here.