【问题标题】:XQuery OSB Transforming String to shortDateXQuery OSB 将字符串转换为 shortDate
【发布时间】:2011-08-15 10:17:47
【问题描述】:

我需要将字符串转换为其中一个 xml 节点上的日期 其中有以下xsd:

  <xs:element minOccurs="0" name="executionDate" type="general:ShortDate"/>

我的字符串格式为 yyyymmdd,我需要将其转换为 ddmmyyyy shortDate 格式。

我正在使用 OSB 并尝试按以下方式进行操作:

{xs:dateTime(xs:date('20041212'))}

我收到以下错误:

<con:reason xmlns:con="http://www.bea.com/wli/sb/context">OSB Insert action failed updating variable "body": {err}XP0021: "20041212": can not cast to {http://www.w3.org/2001/XMLSchema}date: error: date: Invalid date value: wrong type: 20041212</con:reason>

谁能帮帮我?

【问题讨论】:

    标签: xml xquery osb


    【解决方案1】:

    在 XQuery 中,日期由 ISO 格式表示:yyyy-mm-dd。要编译您的查询,您需要将其转换为:

    {xs:dateTime(xs:date('2004-12-12'))}
    

    但是结果是

    2004-12-12T00:00:00
    

    我不认为你在寻找。

    你不能只做这个吗?

    concat(substring($date, 7, 2), substring($date, 5, 2), substring($date, 1, 4))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-03
      • 2023-03-07
      • 1970-01-01
      • 2019-10-10
      • 2019-01-05
      • 2015-01-18
      相关资源
      最近更新 更多