简体   繁体   中英

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:

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

my String is in format yyyymmdd i need to convert it to ddmmyyyy shortDate format.

I'm using OSB and try to do it the following way:

{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. 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))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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