【问题标题】:Query DateTime field using Date only in FileNet Content Engine在 FileNet 内容引擎中仅使用日期查询 DateTime 字段
【发布时间】:2018-04-19 16:13:26
【问题描述】:

是否可以仅使用 IBM FileNet 中的“2017-03-02”等日期字段进行查询?

我已经尝试了下面的语句,但它似乎不起作用

SELECT * 
FROM Table_Name 
WHERE EstimatedDate = '2017-03-02'

SELECT * 
FROM Table_Name 
WHERE EstimatedDate <= DATE '2017-03-02'

我尝试包含 TIMESTAMP 并且以下查询有效,但我只想使用日期搜索,例如 '2017-03-02'

SELECT * 
FROM Table_Name 
WHERE EstimatedDate <= TIMESTAMP '2017-03-02T00:00:00.000Z'

【问题讨论】:

  • 使用 cast 会出现查询语法错误

标签: date filenet-p8 filenet-content-engine filenet-cpe filenet-ce-sql


【解决方案1】:

要搜索特定日期,您需要使用两个时间戳之间的范围:目标日期的开始和第二天的开始。对于今天的日期,查询将是:

SELECT * 
FROM Table_Name 
WHERE EstimatedDate >= 20180420T000000Z AND EstimatedDate < 20180421T000000Z

请注意,上面的时间戳假定为 UTC 时区(因此为000000Z)。如果您的任务应该处理时区,则应相应调整时间戳。例如,对于Europe/Rome(当前时区偏移量+02:00),这将是

EstimatedDate >= 20180419T220000Z AND EstimatedDate < 20180420T220000Z

【讨论】:

    【解决方案2】:

    根据IBM FileNet P8, Version 5.2 - SQL Syntax reference"

    <literal> ::= <string_literal> | <integer> | <float> | 
                  <ISO datetime> | <W3C datetime> | TRUE | FALSE | UNKNOWN | <guid>
    
    <ISO datetime> ::= YYYYMMDDThhmmss[,ffff]Z
    <W3C datetime> ::= YYYY-MM-DD[Thh:mm:ss[.ffff]][<timezone>]
    

    因此,在 FileNet P8 中不要使用 timestampdate 关键字,而只能使用您以其中一种格式编写的日期,并注意 - 没有撇号!

    您可以在免费书籍Developing Applications with IBM FileNet P8 APIs 中找到示例,例如在第 73 页上有Example 3-30

    // Construct the sql statement
    SearchSQL sql = new SearchSQL(
    "select ISTOStartDate, ITSOEndDate, ITSOVehicle " +
    "from ITSOIdleActivity " +
    "where “ +
    "ITSOVehicle = OBJECT('{D5DC8C04-2625-496f-A280-D791AFE87A73}') " +
    "AND ITSOStartDate < 20090801T000000Z OR " +
    "ITSOEndDate > 20090701T000000Z" );
    

    如您所见,此示例中的日期直接写为:20090701T000000Z 使用&lt;ISO datetime&gt; 格式,您也可以使用另一种格式:2009-07-01

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-04-25
      • 1970-01-01
      • 1970-01-01
      • 2019-08-18
      • 2015-06-10
      • 1970-01-01
      • 2012-11-23
      • 2014-04-07
      相关资源
      最近更新 更多