Cross domain request from JavaScript filter on DateTime field.

I am issuing a cross domain request from JavaScript.  The request should filter a standard EventCalendar based on the Start and End times.  Based on this my url looks like this

_api/web/lists/GetByTitle('My%20Event%20Cal')/Items?$filter=EndDate eq datetime'2013-08-02T18:30:00Z'

When this request is executed I get the following error

Microsoft.SharePoint.SPException: The field 'EndDate' of type 'DateTime' cannot be used in the query filter expression

True enough when I create a custom DateTime column and filter on that it works fine.  How do I fix this, I want to filter based on the standard event calendar, I dont want users to create a custom EventCalendar just for my filtering purposes.

August 1st, 2013 5:01am

Hi,

As far as I know you cannot use direct comparisons with DateTime fields using REST (only numeric or string). Check the diagram in this page.

You'd have to get the values out of the DateTime (year, month, etc.) and then perform a numeric comparison.

Free Windows Admin Tool Kit Click here and download it now
August 1st, 2013 4:53pm

Hi. This sounds like a known issue with using OData filters on EventDate and EndDate in calendar lists, and a fix is in the works. I don't know when it will be available but I'll post to this thread when I find out.
August 2nd, 2013 7:53am

I tried this and does not seem to work, it sends back everything irrespective of the filter.
Free Windows Admin Tool Kit Click here and download it now
August 6th, 2013 5:28am

Hi SP Dev101,

Please use ListData.svc instead to filter the EndDate column, format like following:

http://<servername>/_vti_bin/ListData.svc

/Calendar?$filter=StartTime+ge+datetime'2011-11-23'

More information, a similar thread:
http://social.msdn.microsoft.com/Forums/sharepoint/en-US/6c0b65cd-c3e0-4761-a70e-2235736ce0cc/cant-use-eventdate-or-enddate-when-filtering-calendar-items-using-rest-api

Thanks,

August 6th, 2013 5:47am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics