【问题标题】:Query Datetime field in SPList查询 SPList 中的日期时间字段
【发布时间】:2012-07-19 11:31:45
【问题描述】:

您能告诉我如何使用 CAML 查询将作为 DateTime 字段存储在 SPList 中的日期和时间与当前系统时间进行比较吗?

【问题讨论】:

    标签: sharepoint caml splist


    【解决方案1】:

    与今天的日期比较:

    <Where>
      <Lt>
        <FieldRef Name='Created'/>
        <Value type='DateTime'><Today /></Value>
      </Lt>
    </Where>
    

    比较今天的日期和时间

    <Where>
      <Lt>
        <FieldRef Name='Created'/>
        <Value type='DateTime' IncludeDateTime='TRUE'><Today /></Value>
      </Lt>
    </Where>
    

    比较昨天的日期

    <Where>
      <Lt>
        <FieldRef Name='Created'/>
        <Value type='DateTime'><Today Offset='-1' /></Value>
      </Lt>
    </Where>
    

    【讨论】:

      【解决方案2】:

      比较昨天的日期应该是“OffsetDays”

      <Where>
        <Lt>
          <FieldRef Name='Created'/>
          <Value type='DateTime'><Today OffsetDays='-1' /></Value>
        </Lt>
      </Where>
      

      【讨论】:

        猜你喜欢
        • 2018-05-31
        • 2016-07-09
        • 1970-01-01
        • 2011-05-30
        • 2016-07-10
        • 2018-08-06
        • 1970-01-01
        • 1970-01-01
        • 2015-10-01
        相关资源
        最近更新 更多