Marklogic SQL93和日期比较

问题描述 投票:0回答:1

Marklogic内置了SQL93标准,MakLogic中的文档中有一些有关日期函数的详细信息

我有一个简单的查询,可将日期与传入的字符串日期进行比较。但是似乎无法通过SQL93的MarkLogic实现将字符串转换为内联的日期。

我看过标准函数,它们有一个curdate,但不等同于CAST或CONVERT,curdate也不会带参数。

select dateStart from namespace.dateTable
where coalesce(dateStart,curdate())> XXX('1 Nov 2019')

在这种情况下,我想返回2019年11月1日之后的所有日期

sql date marklogic
1个回答
0
投票

需要利用绑定。感谢网站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();
© www.soinside.com 2019 - 2024. All rights reserved.