Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
How to Convert date format in xslt

Hi,

How to convert date format in xslt. I have created application as shown below

I used xml :
--------------

<TRSummary>
    <TravellerRequest>
        <RequestDate>2015-01-06T17:51:01.67+05:30</RequestDate>
    </TravellerRequest>
</TRSummary>

My xslt file :
--------------
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">
    <xsl:output method="html"/>
    <xsl:template match="TRSummary">
        <xsl:value-of select="format-dateTime(TravellerRequest/RequestDate,'[M01]/[D01]/[Y0001]')"/>
    </xsl:template>
</xsl:stylesheet>


in html page getting error :
---------------------------------------

Exception Details: System.Xml.Xsl.XsltException: 'format-dateTime()' is an unknown XSLT function.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

I need output like this:
-----------------------
 01/06/2015

How to convert the above datetime format into mm/dd/yyyy.

plz guide me.

Thanks,
Ram...
Posted

1 solution

This:
SO: Format a date in XML via XSLT[^]
could be interesting.
 
Share this answer
 
Comments
vulisiramu 24-Apr-15 4:36am    
Hi Philo, i checked above link but i am unable to find the solution, please help me.
phil.o 24-Apr-15 4:46am    
And what did you try exactly from the given link? 8 min is quite short to read the posts and state there is no valuable information. Did you even try something?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900