xsl-list
[Top] [All Lists]

RE: [xsl] Sorting date format

2008-12-23 05:59:18
Michael Kay
It's best to avoid date formats such as d/m/y or m/d/y - better to use the
ISO date format yyyy-mm-dd. This is supported directly in XSLT 2.0 via the
data type xs:date. If you're stuck with XSLT 1.0 and/or d/m/y format dates,
you will have to rearrange them into y/m/d format using a combination of
concat() and substring() operations, you can then convert 21/02/05 to
20050221, which you can then sort directly either as a number or as a
string. So it's something like

<xsl:sort select="concat(substring(.,7,2), substring(.,4,2),
substring(.,1,2)"/>

I got the expected. Very nice explanation, Thanks a lot Mr. Michael.

Regards,
Ramkumar


--~------------------------------------------------------------------
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>