字段'事件日期'类型'日期时间'不能在查询筛选器表达式中使用

The field 'EventDate' of type 'DateTime' cannot be used in the query filter expression

本文关键字:日期 表达式 筛选 不能 类型 事件 时间 字段 查询      更新时间:2023-09-26

我正试图通过SharePoint web api过滤标准日历事件,我的查询如下:

/_api/web/lists/getbytitle('calendar')/items?$filter=( EventDate  ge  datetime'2013-01-26T22:00:00Z')&$select=Title,EventDate,ID 

查询不起作用,我收到这个错误:

"DateTime"类型的字段"EventDate"不能用于查询筛选器表达式

错误详细信息:

{"error":{。","type":"Microsoft.SharePoint.SPException","stacktrace":"在Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.CheckFieldRefUsage(SPField字段,FieldRefUsagefieldRefUsage)''r''n在Microsoft.SharePoint.SplistItementityCollectionCamlQuery Builder.SetFieldRefMicrosoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder.SetWhereBinaryOp(XmlWriter编写器,EdmParserNode parseNode)''r''n位于Microsoft.SharePoint/SPListItementityCollectionCamlQuery Builder.SetViewQuery(SPQuery查询,XmlWriter编写程序,StringBuilder sb)''r''n位于Microsoft.SharePoint.SPListItemEntityCollectionCamlQueryBuilder。。ctor(SPList列表,RESTfulQuery restQuery,可为Null的`1 itemId)''r''n位于Microsoft.SharePoint.SPListItemEntityCollection.TryWriteAsOData(ODataWriter写入器,RESTfurQuery查询,ProxyContext ProxyContext)''r''n位于Microsoft.SharePoint.Client.ServerStub.Write(对象值,Uri路径,ODataWriter编写器,RESTfulQuery查询,ProxyContext ProxyContext)Microsoft.SharePoint.Client.Rest.RestRequestProcessor.Process()''r''n位于Microsoft.SharePoint.Client.Rest.RestRequestProcessor.PProcessRequest()''r''n,位于Microsoft.SharePoint.Client.Rust.RestService.ProcessQuery(流输入流,IList`1 pendingDisposableContainer))","internalexception":{"message":"类型为'DateTime'的字段'EventDate'不能在查询筛选器表达式中使用。","type":"Microsoft.SharePoint.Client.InvalidClientQueryException","stacktrace":"{}}"

是否可以以某种方式在筛选查询表达式中使用DateTime类型的字段?

更新:我发现我可以通过ListData.svc来做到这一点,例如

/_vti_bin/ListData.svc/Calendar?$filter=StartTime+ge+datetime'2011-11-23'

更多详细信息,请点击此处-http://itblog.wolthaus.net/2011/12/rest-filter-datetime/

我试图从/''api/web/查询中删除时间部分,例如

/_api/web/lists/getbytitle('calendar')/items?$filter=( EventDate  ge  '2013-01-26')&$select=Title,EventDate,ID

但这无济于事,我也犯了同样的错误。

尝试web服务(旧的、非REST)端点。这就是我在项目中使用的内容。REST端点也有许多其他Odata构造的问题(例如$skip)。

https://.../_vti_bin/ListData.svc/Calendar?$select=Title,EventDate,ID&$filter=EventDate ge datetime'2013-01-26'