sql server - Convert varchar dd-mmm-yyyy to dd/mm/yyyy then order by not working? -
i have situation
i need convert
varchar
valuedd-mmm-yyyy
dd/mm/yyyy
order above converted date
using
convert(varchar(10), cast([date] datetime), 103) modifieddate
i got required format but, when order modifieddate
order result set showing 2013, 2014, 2015 years mixed match. think doing order date. doing wrong? can help?
since modifieddate
varchar, ordering lexical (01/01/1900
< 01/01/1901
< 02/01/1900
).
the solution not use varchar sorting. convert varchar-date real date (i.e., cast([date] datetime)
without outer convert
) , sort expression.
Comments
Post a Comment