8

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

1408786user
  • 1,868
  • 1
  • 21
  • 39

1 Answers1

19

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

1408786user
  • 1,868
  • 1
  • 21
  • 39
  • 4
    For c#, you'd use `DateTime.UtcNow.ToString("O")` to get the correct format. – Matty Aug 27 '18 at 22:45
  • 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" } }` – Sandeep Tripathi Jun 28 '21 at 06:24