You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power Automate中Get Items步骤ODATA日期过滤查询报错求助

Power Automate Get Items OData日期筛选报错解决方法

你遇到的问题核心是SharePoint的OData筛选查询不支持在列表字段上直接使用Power Automate的formatDateTime函数,这才导致了“查询无效”的错误。

正确的筛选写法

不需要对日期字段做格式化处理,直接利用日期时间类型的原生比较逻辑即可,以下是两种可行方案:

方案1:直接比较日期时间(包含时间部分)

构造查询时直接用ImplementationDateTime和计算出的7天前UTC时间比较,Power Automate的addDays函数会返回标准ISO 8601格式的日期时间,SharePoint OData可以直接识别:

CABType eq 'Standard' and CABStatus eq 'Submitted' 
and ImplementationDateTime gt '@{addDays(utcNow(), -7)}'

运行时生成的查询类似:

CABType eq 'Standard' and CABStatus eq 'Submitted' 
and ImplementationDateTime gt '2024-04-09T12:34:56Z'

方案2:精确筛选最近7天的日期(忽略时间)

如果需要只按日期筛选(不管具体时分秒),可以用startOfDay函数获取7天前当天的0点UTC时间,这样就能覆盖全天的记录:

CABType eq 'Standard' and CABStatus eq 'Submitted' 
and ImplementationDateTime ge '@{startOfDay(addDays(utcNow(), -7))}'

运行时生成的查询类似:

CABType eq 'Standard' and CABStatus eq 'Submitted' 
and ImplementationDateTime ge '2024-04-09T00:00:00Z'

为什么原写法不行

OData筛选有自己的内置函数规则,Power Automate的formatDateTime属于流程级别的函数,不能嵌入到OData查询中去处理SharePoint列表的字段。原写法相当于要求SharePoint的OData服务执行Power Automate的函数,这是不被支持的。

验证方法

替换查询后,查看Get Items步骤生成的最终查询语句,确保日期部分是YYYY-MM-DDTHH:MM:SSZ的标准ISO格式,即可正常执行筛选。

内容的提问来源于stack exchange,提问作者Our Man in Bananas

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 16:29:56