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

SharePoint REST API中DateTime字段空值检查方法求助

SharePoint REST API 查询DateTime字段空值的解决办法

方法1:使用IsNull函数

SharePoint REST API支持通过IsNull函数判断字段是否为空,语法如下:

/_api/web/lists/getbytitle('你的列表名')/items?$filter=IsNull(Date字段名)

示例(假设DateTime字段名为ExpirationDate):

/_api/web/lists/getbytitle('Documents')/items?$filter=IsNull(ExpirationDate)

方法2:对比SharePoint默认空DateTime值

未设置的DateTime字段在SharePoint中会被存储为0001-01-01T00:00:00Z,可直接对比该值筛选空值:

/_api/web/lists/getbytitle('你的列表名')/items?$filter=Date字段名 eq datetime'0001-01-01T00:00:00Z'

示例(假设DateTime字段名为DueDate):

/_api/web/lists/getbytitle('Tasks')/items?$filter=DueDate eq datetime'0001-01-01T00:00:00Z'

补充:筛选非空DateTime值

如果需要筛选有值的DateTime字段,可使用以下两种方式:

  • 用Not包裹IsNull函数:
    $filter=Not(IsNull(ExpirationDate))
    
  • 对比不等于默认空值:
    $filter=DueDate ne datetime'0001-01-01T00:00:00Z'
    

内容的提问来源于stack exchange,提问作者Maite Fernandez

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.20 05:42:01