0

我正在尝试查找本周中“星期日”的日期。这是代码,我有:

let $today := fn:current-date()
let $day-week := functx:day-of-week($today)
let $start-date := xs:date($today)-xs:dayTimeDuration($day-week)

$today -> 有今天的日期
$day-week -> 是 5(星期五的值)

我想,当我做 $today-5 时,我会得到 2013 年 7 月 14 日。

但是,这没有用。请更正我的代码。感谢您的帮助。

4

2 回答 2

0

functx:day-of-week($today)返回xs:integer不会转换为xs:dayTimeDuration. 只需将该整数乘以有效持续时间而不是强制转换:

let $today := fn:current-date()
let $day-week := functx:day-of-week($today)
let $start-date := xs:date($today)-($day-week*xs:dayTimeDuration('P1D'))
于 2013-07-19T22:49:21.500 回答
0

我认为 xs:dayTimeDuration 需要更多设置。试试这样的:

let $today := fn:current-date()
let $day-week := functx:day-of-week($today)
let $start-date := xs:date($today)-(xs:dayTimeDuration('P1D')*$day-week)

在此处获取更多信息:

http://pic.dhe.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=%2Fcom.ibm.db2z10.doc.xml%2Fsrc%2Ftpc%2Fdb2z_xsdaytimeduration.htm

于 2013-07-19T22:52:34.580 回答