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.
Author |
Topic |
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-08-10 : 06:00:04
|
I have the following query -select * from tablex where mystatus='matched' order by sitename,mydate,mytimenow mydate and mytime are varchar fields with values such as:1/7/2006 for date and 0:05:25 for timemy problems is when sorting it the time of 10:50 will come before 9:50. I assume this is because i am using a string. can you use a datetime field and keep the date separate then the time? what can i do to fix it so the 10 will come after 9? |
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2006-08-10 : 06:10:45
|
change 9 to 09. 09 is < 10.*##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here! |
 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-08-10 : 06:18:31
|
i'm actually working with existing data (imported from excel) -- are there any other ways to do it? |
 |
|
Wanderer
Master Smack Fu Yak Hacker
1168 Posts |
Posted - 2006-08-10 : 06:22:55
|
I'm not really an ms-access guy - I just thought/hoped that the quick answer might help :-(I'm not sure whqat functions you have in access.I would suggest changing the select * into an explicit select, i.e. select columnname, columnname2, ...Do you have cast functions in access?*##* *##* *##* *##* Chaos, Disorder and Panic ... my work is done here! |
 |
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-10 : 10:34:38
|
Can't u use Format function in ur Order By ?I think U can format to Date formats Time Formats seperately.Srinika |
 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2006-08-10 : 10:55:49
|
how? |
 |
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-08-10 : 11:12:45
|
SELECT * FROM T1 order by Format(F1,"HH:MM:SS")Srinika |
 |
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2006-08-15 : 14:11:48
|
[code]select * from tablex where mystatus='matched' order by sitename, format(mydate, "yyyymmdd"), format(mytime, "hh:mm:ss")[/code]Peter LarssonHelsingborg, Sweden |
 |
|
|
|
|
|
|