Question

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?

Was it helpful?

Solution

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))
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top