Azure search filter Edm.DateTimeOffset
Asked Answered
K

1

9

I have an azure search index for a table with a field with datatype Edm.DateTimeOffset. And the following filter: $filter=MyDateTimeOffset ge '4/14/2017 6:35:05 AM +00:00' and MyDateTimeOffset le '4/14/2017 7:45:01 AM +00:00'

Invalid expression: A binary operator with incompatible types was detected. Found operand types 'Edm.DateTimeOffset' and 'Edm.String' for operator kind 'LessThanOrEqual'.\r\nParameter name: $filter"

EDIT:

Problem solved, I changed my datetime format to: yyyy-MM-ddTHH:mm:ssZ and removed the quotes

Example: $filter=Timestamp ge 2017-04-14T06:35:05Z

Kemberlykemble answered 14/4, 2017 at 9:10 Comment(1)
Glad you solved it! Please copy your solution into an answer so that others can find it easily.Dejesus
K
20

Problem solved, I changed my datetime format to: yyyy-MM-ddTHH:mm:ssZ and removed the quotes

Example: $filter=Timestamp ge 2017-04-14T06:35:05Z

Kemberlykemble answered 18/4, 2017 at 12:48 Comment(2)
For c#, you'd use DateTime.UtcNow.ToString("O") to get the correct format.Clew
This works with GET Verb but with POST, I am using filter like : {"filter":"Date ge 2017-04-14T06:35:05Z","top":100,"skip":0,"orderby":"code asc","count":true,"search":"*"} and it give 400 with below response { "error": { "code": "", "message": "The request is invalid. Details: parameters : Invalid JSON. Unexpected end of input was found in JSON content. Not all object and array scopes were closed.\r\n" } }Eversion

© 2022 - 2024 — McMap. All rights reserved.