Reputation: 67
I am new to xslt. so this might be a basic question. I am trying to convert a date received in xs:date format to xs:dateTime
input received is :
<tns:receivedDate>2017-06-27</tns:receivedDate>
I want to transform it to 2017-06-27T00:00:00.000-05:00
or 2017-06-27T00:00:00.000
i tried the statement below but doesnt work
<tns:receivedDate>xs:date(<xsl:value-of select="//ns0:receivedDate"/>)cast as xs:dateTime</tns:receivedDate>
Please let me know what is missing. thanks
Upvotes: 0
Views: 1463
Reputation: 1882
In XSLT 2.0+ you could just use
xs:dateTime(xs:date('2017-06-27'))
But you have tagged this as XSLT 1.0, wich left you with just a string concatenation:
<tns:receivedDate>
<xsl:value-of select="concat(//ns0:receivedDate,'T00:00:00.000')"/>
</tns:receivedDate>
Upvotes: 2
Reputation: 117073
XSLT 1.0 has no concept of dates. You need to do this using string manipulation - for example:
<tns:receivedDate>
<xsl:value-of select="//ns0:receivedDate"/>
<xsl:text>T00:00:00.000</xsl:text>
</tns:receivedDate>
Upvotes: 1