Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Why ORDER BY isn´t working?

Author  Topic 

vectords
Starting Member

3 Posts

Posted - 2003-11-19 : 09:47:24
Again, Hi everybody,
I have onde table called (TB) with two fields : F1(int) and F2(varchar:10)
In this table the field F2 is used to store dates in the format
dd/mm/yyyy (27/12/2002). It´s is record as varchar and undesired.
I need to select all records from a single id from the field F1 and
then order by the result set by date to result set be this way:


To do this I´m using the follow syntax :

SELECT * FROM TB
WHERE (F1 = '01')
ORDER BY CONVERT(varchar(10), F2, 103)

My problem is that the result set isn´t order by displaying as follow :


F1 F2
--------------------------------------
01 05/07/1975
01 07/01/2000
01 12/12/1985
01 13/12/1998
--------------------------------------

I need a real ordey by date to get the follow result set for this select :


F1 F2
--------------------------------------
01 05/07/1975
01 12/12/1985
01 13/12/1998
01 07/01/2003
--------------------------------------
If there´s someone to solve this problem I´ll be thankfull

more one time...thanks for attetion

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2003-11-19 : 09:55:33
[code]
order by convert(datetime,F2,103)
[/code]
Go to Top of Page
   

- Advertisement -