简体   繁体   English

MarkLogic Optic API:使用 op:where() 过滤时间戳超过 30 天的行

[英]MarkLogic Optic API: Filtering rows with op:where() with timestamps older than 30 days

In my dataset I have a field testDateTime that contains xs:dateTime timestamps: 2022-06-02T10:42:00Z在我的数据集中,我有一个包含 xs:dateTime 时间戳的字段 testDateTime: 2022-06-02T10:42:00Z

Using the optic API and op:where() , is there a way I can filter my results to exclude any rows with timestamps older than 30 days?使用光学 API 和op:where() ,有没有办法可以过滤我的结果以排除时间戳超过 30 天的任何行?

I have been attempting to use the following SQL statements in op:like-sql-condition() but do not look to be supported:我一直在尝试在op:like-sql-condition()中使用以下 SQL 语句,但看起来不受支持:

=>op:where(op:sql-condition("MyData.testDateTime < CURRENT_DATE - 30"))
=>op:where(op:sql-condition("MyData.testDateTime < DATEADD(day, -30, GETDATE())"))
=>op:where(op:sql-condition("MyData.testDateTime < NOW() - INTERVAL 30 DAY"))
=>op:where(op:sql-condition("MyData.testDateTime < GETDATE() - 30"))

Is there a way to get this working either with a SQL condition or with optic operators themselves?有没有办法让这个工作与 SQL 条件或光学操作员本身一起工作?

What about just using op:lt() and testing whether the testDateTime column is less than currentDateTime() - xs:dayTimeDuration("P30D") :仅使用op:lt()并测试testDateTime列是否小于currentDateTime() - xs:dayTimeDuration("P30D")

=> op:where(op:lt(op:col("MyData.testDateTime"), current-dateTime() - xs:dayTimeDuration("P30D")))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Marklogic - 光学 API:按值连接视图(op:on 不支持值,仅支持列引用) - Marklogic - Optic API: Joining views by value (op:on does not support values, only column-references) 在 Marklogic Xquery 中删除少于 30 天的文档 - Delete documents less than 30 days in Marklogic Xquery 为什么我的 Optic API 查询的结果不是我在排序和过滤时所期望的? - Why are the results of my Optic API query not what I'm expecting when sorting and filtering? 声明变量中的列在光学查询 MarkLogic 中不起作用 - Declare column in variable is not working in Optic query MarkLogic MarkLogic 中的光学查询错误 - 无效强制:map:map - Error in Optic query in MarkLogic - Invalid coercion: map:map 使用两个索引的 MarkLogic 光学查询不返回任何结果 - MarkLogic optic query using two indexes returns no results MarkLogic sem:MarkLogic Java API中的功能组 - MarkLogic sem: function group in MarkLogic Java API 如何使用光学 API 加入具有相似值的视图? - How do you join views with similar values with the Optic API? MarkLogic 光学查询中的错误 - 获取模板视图文档中记录出现的百分比 - Error in MarkLogic Optic Query - to get percentage of occurrence of a record in a template view document MarkLogic Xquery 查找彼此相隔 1 分钟内的所有时间戳 - MarkLogic Xquery finding all timestamps within 1 minute of eachother
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM