View Full Version : Sorting a query by the time in a DATETIME field
bdittmer
02-09-2005, 12:23 AM
Hey guys...I'm trying to write a query that will sort a bunch of rows (using ORDER BY) by just the time fields in a DATETIME field type. I'm not even sure if this is possible or if anyone has actually tried to do it before. :P Any help would be appreciated!
- Brian
Brandoe85
02-09-2005, 12:25 AM
Welcome to the forums.
select Fields from table order by dateField DESC ?
Perhaps you can explain a little more?
bdittmer
02-09-2005, 12:30 AM
A DATETIME time field in MySQL has the format: 0000-00-00 00:00:00
I'd like to just sort by the time or date portion of this, for example 0000-00-00 or 00:00:00.
- Brian
Brandoe85
02-09-2005, 12:38 AM
My bad, I misread your post. Try:
select DateField from table order by right(DateField,9) DESC;
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.