Xquery 总结部分 DayTime 持续时间

发布于 2024-10-02 20:01:16 字数 293 浏览 0 评论 0原文

我在使用 sum 总结持续时间时遇到问题。

这是一个例子:

<total>
for $t in //Times
let $start_t := $t/@start
let $stop_t := $t/@stop
let $duration := xs:dateTime($stop_t) - xs:dateTime($start_t)
return
..... 
</total>

给我一个部分持续时间的列表。我如何使用 sum 来总结它们?

谢谢

I have a problem with summing up durations using sum.

here is an example:

<total>
for $t in //Times
let $start_t := $t/@start
let $stop_t := $t/@stop
let $duration := xs:dateTime($stop_t) - xs:dateTime($start_t)
return
..... 
</total>

gives me a list of partial durations. How do I sum them up using sum?

thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

世界如花海般美丽 2024-10-09 20:01:16

您可以使用以下 XQuery/XPath 表达式:

sum(//Times/(xs:dateTime(@stop) - xs:dateTime(@start)))

You could use this XQuery/XPath expression:

sum(//Times/(xs:dateTime(@stop) - xs:dateTime(@start)))
人│生佛魔见 2024-10-09 20:01:16

您可以将整个查询包装在对 sum() 的调用中:

<total>
{
  sum(
    for $t in //Times
    let $start_t := $t/@start
    let $stop_t := $t/@stop
    return xs:dateTime($stop_t) - xs:dateTime($start_t)
  )
}
</total>

You can just wrap the whole query in a call to sum():

<total>
{
  sum(
    for $t in //Times
    let $start_t := $t/@start
    let $stop_t := $t/@stop
    return xs:dateTime($stop_t) - xs:dateTime($start_t)
  )
}
</total>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文