sql - Marklogic SQL93 和日期比较
问题描述
Marklogic 内置了 SQL92 标准,MakLogic 中的文档有一些关于日期函数的详细信息
我有一个简单的查询来将日期与传入的字符串日期进行比较。但似乎没有办法将字符串转换为与 SQL92 的 MarkLogic 实现内联的日期。
我查看了标准函数,它们有一个 curdate,但不等同于 CAST 或 CONVERT,curdate 也不会带参数。
select dateStart from namespace.dateTable
where coalesce(dateStart,curdate())> XXX('1 Nov 2019')
在这种情况下,我想返回 2019 年 11 月 1 日之后的所有日期
解决方案
需要使用绑定。感谢网站Avalon。
const minYear = xs.date('2019-11-01');
//create a binding with the date being passed as a date
var bindings = {"date": minYear};
//add to the SQL the variable @date
var sqlString = `select * from namespace.table
where dateStart >= @date limit 100
`;
//execute the sql with third argument the binding
xdmp.sql(sqlString, null, bindings).toArray();
推荐阅读
- python - 如何在tensorflow中编写没有内存泄漏的流函数
- python - 如何在 RelStorage 包中删除 blob?
- r - 使用R删除时间序列中连续零值之前的行
- c++ - 如何使用 cmake 生成器表达式为不同的编译器添加编译器标志?
- spring-data - 使用 CosmosDB 中的 Spring Data 返回嵌套对象的不同值
- swiftui - swiftUI 在计算 ZStack 元素的数据之前运行函数的同步问题
- r - 使用辅助数据框定义的变量计算唯一值
- regex - 正则表达式匹配字符串中相同子字符串中的最后一个子字符串
- java - Passay 生成不是旧密码的密码
- javascript - 是否可以在 JavaScript 或 TypeScipe 的自定义类中实现索引器?