I am trying to convert my datetime to 107 ex: Dec 11 2006 ,but when sorting I get the months sorted correctly but not by year?
ex:
Jan 2004
Feb 2001
Mar 2006
Can you post the code you are using to do this? That is kind of a wierd way to sort data. I can't think of any way your daa would be sorted this way by using a typical order by clause.
create table testDateSort
(
date smalldatetime
)
insert into testDateSort
select '20040101'
union all
select '20010201'
union all
select '20060301'
go
select convert(varchar(20),date,107)
from testDateSort
order by date
returns:
--
Feb 01, 2001
Jan 01, 2004
Mar 01, 2006
No comments:
Post a Comment