Groups > Design > Microsoft xsl > Re: sorting on date column in XSL




sorting on date column in XSL

sorting on date column in XSL
Mon, 17 Mar 2008 21:56:23 -070
hi
I want to sort my data using XSl. I am using
<xsl:sort  select="*[name(.)=$SortCol]"
order="{$SortOrder}" data-
type="{$dataType}"/>
this xommand for sorting

But one of my column is of type date. so how do I specify the datatype
Post Reply
Re: sorting on date column in XSL
Mon, 17 Mar 2008 23:04:49 -070
On Mar 18, 9:56 am, Palwi <palwich...@gmail.com> wrote:
> hi
> I want to sort my data using XSl. I am using
> <xsl:sort  select="*[name(.)=$SortCol]"
order="{$SortOrder}" data-
> type="{$dataType}"/>
> this xommand for sorting
>
> But one of my column is of type date. so how do I specify the datatype
> for date. My date format is dd mon yyyy

1. you are using XSL 1.0 or 2.0?
2. If you are using xsl 1.0  this doesn't have datatypes like date,
time, integer, etc.

    You split the date and sort it. e.g

<xsl:sort select="substring-before(' ',date)"
data-type="number"/>

Regards,
Balaji. M
Post Reply
Re: sorting on date column in XSL
Tue, 18 Mar 2008 12:45:39 +010
Palwi wrote:

> I want to sort my data using XSl. I am using
> <xsl:sort  select="*[name(.)=$SortCol]"
order="{$SortOrder}" data-
> type="{$dataType}"/>
> this xommand for sorting
> 
> But one of my column is of type date. so how do I specify the datatype
> for date. My date format is dd mon yyyy

XSLT 2.0 supports the xs:date data type but it has the format yyyy-mm-dd 
so you would need to reorder your date strings.
With XSLT 1.0 you need to sort numbers or strings, you can do that also 
by reordering your date strings in the format yyyymmdd.

-- 

	Martin Honnen --- MVP XML
Post Reply
about | contact