Re: [xsl] Xquery ->Convert string to datetime

Subject: Re: [xsl] Xquery ->Convert string to datetime
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Sun, 26 Sep 2010 16:26:22 -0400
At 2010-09-26 11:52 -0700, sudheshna iyer wrote:
I wanted to convert "2010-06-14" to xs:datetime ->2010-06-14T00:00:00Z using Xquery. Are there any functions to achieve this without writing java code?

t:\ftemp>type iyer.xq dateTime(xs:date('2010-06-14'),xs:time('00:00:00')) t:\ftemp>xquery iyer.xq <?xml version="1.0" encoding="UTF-8"?>2010-06-14T00:00:00 t:\ftemp>type iyer.xsl <?xml version="1.0" encoding="US-ASCII"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; xmlns:xsd="http://www.w3.org/2001/XMLSchema"; version="2.0">

<xsl:output method='text'/>

<xsl:template match="/">
<xsl:value-of select="dateTime(xsd:date('2010-06-14'),xsd:time('00:00:00'))"/>


</xsl:template>

</xsl:stylesheet>
t:\ftemp>xslt2 iyer.xsl iyer.xsl
2010-06-14T00:00:00
t:\ftemp>

If this is not the right forum, can you suggest the correct mailing list to post this question?

This is not the correct forum for XQuery questions, but since the answer is based on XPath, I've included an XSLT solution above, under the XQuery solution.


The XQuery list I monitor is http://www.x-query.com/mailman/listinfo/talk

I hope this helps.

. . . . . . . . . Ken

--
XSLT/XQuery training:   after http://XMLPrague.cz 2011-03-28/04-01
Vote for your XML training:   http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread