Question

I have a query like this

select * from xxx where dates between '2012-10-26' and '2012-10-27'.

and did as URL like

url/?$filter=dates gt datetime'2012-10-26' and dates lt datetime'2012-10-27'

and I am getting response by using this one.

Now, I need to get by time, so I changed the URL to

&$filter=LastModifiedDate+ge+datetime'2012-09-25 23:59:59'

But I am getting an error:

{"odata.error":{"code":"","message":{"lang":"en-US","value":"Unrecognized 'Edm.DateTime' literal 'datetime'2012-09-25 12:00:00'' at '20' in 'LastModifiedDate ge datetime'2012-09-25 12:00:00''."}}}

Was it helpful?

Solution

Short answer

dateTimeOffsetValue = year "-" month "-" day "T" hour ":" minute [ ":" second [ "." fractionalSeconds ] ] ( "Z" / sign hour ":" minute )

Example: 2000-01-01T16:00:00.000Z


The edm:Date expression evaluates to a primitive date value. A date expression MUST be assigned a value of type xs:date, see [XML-Schema-2], section 3.3.9. The value MUST also conform to rule dateValue in [OData-ABNF], i.e. it MUST NOT contain a time-zone offset.

date represents top-open intervals of exactly one day in length on the timelines of dateTime, beginning on the beginning moment of each day, up to but not including the beginning moment of the next day). For non-timezoned values, the top-open intervals disjointly cover the non-timezoned timeline, one per day. For timezoned values, the intervals begin at every minute and therefore overlap.

Hence, what you want here is a DateTimeOffset:

The edm:DateTimeOffset expression evaluates to a primitive date/time value with a time-zone offset. A date/time expression MUST be assigned a value of type xs:dateTimeStamp, see [XML-Schema-2], section 3.4.28. The value MUST also conform to rule dateTimeOffsetValue in [OData-ABNF], i.e. it MUST NOT contain an end-of-day fragment (24:00:00).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top