Home Forums SQL Server 2008 SQL Server 2008 - General How to order by month which is varchar field according to date format? RE: How to order by month which is varchar field according to date format?
subbu1
Hall of Fame
Points: 3281
More actions
August 8, 2012 at 12:07 am
#1522963
pls try below code
declare @t1 table(id varchar(10))
insert into @t1(id)values('Jan-12'),('Feb-12'),('Mar-12'),('APR-12')
select *,convert(date,convert(varchar(10),'01'+'-'+id)) new from @t1
order by 2