selva kumar

selva kumar

  • NA
  • 557
  • 189k

how to sort the date in dd mm yyyy

May 11 2013 3:18 AM
This is my code:

create table [sample](T_id int identity(1,1),date varchar(50));


insert into [sample] values('04-05-2013');
insert into [sample] values('07-03-2013');
insert into [sample] values('10-01-2013');
insert into [sample] values('20-08-2013');
insert into [sample] values('18-02-2013');
insert into [sample] values('09-07-2013');
insert into [sample] values('07-06-2013');
insert into [sample] values('05-12-2013');
insert into [sample] values('05-12-2013');
insert into [sample] values('05-12-2013');

if i m using below query:

select distinct Convert(datetime,date,105)as date from [sample] order by date desc;

im getting this out put:

2013-12-05 00:00:00.000
2013-08-20 00:00:00.000
2013-07-09 00:00:00.000
2013-06-07 00:00:00.000
2013-05-04 00:00:00.000
2013-03-07 00:00:00.000
2013-02-18 00:00:00.000
2013-01-10 00:00:00.000

this is my problem......

i want to  get the out put like this

05-12-2013
20-08-2013
09-07-2013
07-06-2013
04-05-2013
07-03-2013
18-02-2013
10-01-2013

How do i Get This ...help Me...i am trying past two days.....help me quickly..........


Answers (24)