2019-04-10

Difference between 2 dates in XQuery

package require xqilla

xqilla db
set exprs [db prepare {days-from-duration(xs:dateTime('2019-06-14T00:00:00') - current-dateTime())}]
set result [$exprs execute]
set diff 0

while {[$result next]} {
    set diff [$result string_value]
}

puts "The answer is $diff."

$result close
$exprs close
db close

使用 XQuery 的日期函式計算出二個日期間的差距,這裡使用 XQilla 測試。

沒有留言: