[xsl] convert String to date format and sort

Subject: [xsl] convert String to date format and sort
From: Anil Kumar Veeramalli <anil.v@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 29 Oct 2009 15:11:42 +0530

1) my current date format is 28-Oct-1987(dd-mmm-yyyy), want to convert it yyyy-mm-dd format.
2) sort the dates

XML code:
<Employee startdate="11/20/1999">
<Employee startdate="07/06/2001">
<Employee startdate="04/23/1999">

xslt code to sort by date:
<xsl:template match="Employee">
<xsl:sort select="substring(@startdate,7,4)"/> <!-- year sort -->
<xsl:sort select="substring(@startdate,1,2)"/> <!-- day sort -->
<xsl:sort select="substring(@startdate,4,2)"/> <!-- month sort -->

sorting this way is good approach or do we have any better approach.


Current Thread