Note that there are some explanatory texts on larger screens.

plurals
  1. POThe field 'EventDate' of type 'DateTime' cannot be used in the query filter expression
    text
    copied!<p>I am trying to filter standard Calendar events via SharePoint web api and my query looks like this:</p> <pre><code>/_api/web/lists/getbytitle('calendar')/items?$filter=( EventDate ge datetime'2013-01-26T22:00:00Z')&amp;$select=Title,EventDate,ID </code></pre> <p>Query doesn't work and I receive this error:</p> <blockquote> <p>The field 'EventDate' of type 'DateTime' cannot be used in the query filter expression</p> </blockquote> <p>Error Details:</p> <pre> {"error":{"code":"-1, Microsoft.SharePoint.SPException","message":{"lang":"en-US","value":"The field 'EventDate' of type 'DateTime' cannot be used in the query filter expression."},"innererror":{"message":"The field 'EventDate' of type 'DateTime' cannot be used in the query filter expression.","type":"Microsoft.SharePoint.SPException","stacktrace":" at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.CheckFieldRefUsage(SPField field, FieldRefUsage fieldRefUsage)\r\n at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.SetFieldRef(XmlWriter writer, String fieldPath, FieldRefUsage fieldRefUsage, Action`1 attributeAction)\r\n at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.SetWhereBinaryOp(XmlWriter writer, EdmParserNode parseNode)\r\n at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.SetViewQuery(SPQuery query, XmlWriter writer, StringBuilder sb)\r\n at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.BuildCamlQuery()\r\n at Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder..ctor(SPList list, RESTfulQuery restQuery, Nullable`1 itemId)\r\n at Microsoft.SharePoint.SPListItemEntityCollection.TryWriteAsOData(ODataWriter writer, RESTfulQuery query, ProxyContext proxyContext)\r\n at Microsoft.SharePoint.Client.ServerStub.Write(Object value, Uri path, ODataWriter writer, RESTfulQuery query, ProxyContext proxyContext)\r\n at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.Process()\r\n at Microsoft.SharePoint.Client.Rest.RestRequestProcessor.ProcessRequest()\r\n at Microsoft.SharePoint.Client.Rest.RestService.ProcessQuery(Stream inputStream, IList`1 pendingDisposableContainer)","internalexception":{"message":"The field 'EventDate' of type 'DateTime' cannot be used in the query filter expression.","type":"Microsoft.SharePoint.Client.InvalidClientQueryException","stacktrace":""}}}} </pre> <p>Is it possible somehow to use fields type of DateTime in filter query expressions?</p> <p>Update: I found that I can do this via ListData.svc, e.g. </p> <pre><code>/_vti_bin/ListData.svc/Calendar?$filter=StartTime+ge+datetime'2011-11-23' </code></pre> <p>More details here - <a href="http://itblog.wolthaus.net/2011/12/rest-filter-datetime/" rel="nofollow">http://itblog.wolthaus.net/2011/12/rest-filter-datetime/</a></p> <p>I tried to remove the time part from the /_api/web/ query, e.g. </p> <pre><code>/_api/web/lists/getbytitle('calendar')/items?$filter=( EventDate ge '2013-01-26')&amp;$select=Title,EventDate,ID </code></pre> <p>But it didn't help and I got the same error.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload