简体   繁体   English

XQuery OSB 将字符串转换为 shortDate

[英]XQuery OSB Transforming String to shortDate

I need to convert String to the date on one of the xml nodes which has the following xsd:我需要将字符串转换为 xml 节点之一上的日期,该节点具有以下 xsd:

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

my String is in format yyyymmdd i need to convert it to ddmmyyyy shortDate format.我的字符串格式为 yyyymmdd 我需要将其转换为 ddmmyyyy shortDate 格式。

I'm using OSB and try to do it the following way:我正在使用 OSB 并尝试按以下方式进行操作:

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

and I'm getting the following error:我收到以下错误:

<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>

Can anybody just help me?任何人都可以帮助我吗?

In XQuery, a date is represented by the ISO format: yyyy-mm-dd.在 XQuery 中,日期由 ISO 格式表示:yyyy-mm-dd。 To make your query compile, you want to convert this to:为了使您的查询编译,您希望将其转换为:

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

but then the result is但结果是

2004-12-12T00:00:00

which I don't think you are looking for.我不认为你正在寻找。

Can you not just do this?你不能这样做吗?

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM