xsl-list
[Top] [All Lists]

[xsl] convert String to date format and sort

2009-10-29 05:42:14
Hi,

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">
<name>John</name>
</Employee>
<Employee startdate="07/06/2001">
<name>John</name>
</Employee>
<Employee startdate="04/23/1999">
<name>John</name>
</Employee>

xslt code to sort by date: <xsl:template match="Employee">
<xsl:apply-templates>
<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 -->
</xsl:apply-templates>
</xsl:apply-templates>


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



Thanks,
Anil



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>
  • [xsl] convert String to date format and sort, Anil Kumar Veeramalli <=