Amra
Amra

Reputation: 25220

Convert date from yyyy-mm-dd to dd-mm-yy using xsl

HI all, I got a JavaScript function to convert the date, but I was wondering if there is any way to convert the date with xsl without using JavaScript.

Thanks.

Upvotes: 1

Views: 6994

Answers (5)

whitehat
whitehat

Reputation: 2391

Found a very good post on date formatting here.

No Javascript required. Only XSL elements and XPath String functions can do the job.

Upvotes: 0

jjacka
jjacka

Reputation: 531

You can use the Microsoft formatter.

Or the format-date function, if you are using XSLT 2.0 (which .Net does not).

Upvotes: 1

John Boker
John Boker

Reputation: 83719

The format-date function might do the job.

Upvotes: 1

Amra
Amra

Reputation: 25220

Thanks to all of you for answering my question, after looking on those links you left me to take a look I came out with something very simple.

<xsl:for-each select="//MaternityDiaryEvent/DateOfVisit">
<xsl:value-of select="concat(substring(.,9,2),'/',substring(.,6,2),'/',substring(.,3,2))"/>
</xsl:for-each>

Thanks again to all, I'll give you a vote to each of you.

Cesar.

Upvotes: 1

Dyno Fu
Dyno Fu

Reputation: 9044

and the string manipulation, http://www.xml.com/pub/a/2002/05/01/xslt-string.html

Upvotes: 1

Related Questions