sql server - Convert varchar dd-mmm-yyyy to dd/mm/yyyy then order by not working? -


i have situation

  1. i need convert varchar value dd-mmm-yyyy dd/mm/yyyy

  2. 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

Popular posts from this blog

How to run C# code using mono without Xamarin in Android? -

c# - SharpSsh Command Execution -

python - Specify path of savefig with pylab or matplotlib -