Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Old 02-09-2005, 12:23 AM   PM User | #1
bdittmer
New to the CF scene

 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
bdittmer is an unknown quantity at this point
Sorting a query by the time in a DATETIME field

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
bdittmer is offline   Reply With Quote
Old 02-09-2005, 12:25 AM   PM User | #2
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,435
Thanks: 2
Thanked 38 Times in 38 Posts
Brandoe85 will become famous soon enough
Welcome to the forums.

select Fields from table order by dateField DESC ?

Perhaps you can explain a little more?
__________________
-Brando
Why using tables for eating is stupid!
Brandoe85 is offline   Reply With Quote
Old 02-09-2005, 12:30 AM   PM User | #3
bdittmer
New to the CF scene

 
Join Date: Feb 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
bdittmer is an unknown quantity at this point
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
bdittmer is offline   Reply With Quote
Old 02-09-2005, 12:38 AM   PM User | #4
Brandoe85
teh Moderatorinator


 
Join Date: Sep 2004
Location: USA
Posts: 2,435
Thanks: 2
Thanked 38 Times in 38 Posts
Brandoe85 will become famous soon enough
My bad, I misread your post. Try:
select DateField from table order by right(DateField,9) DESC;
__________________
-Brando
Why using tables for eating is stupid!

Last edited by Brandoe85; 02-09-2005 at 12:45 AM.. Reason: Had to fix something
Brandoe85 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:24 AM.

Home - Contact Us - Archives - Link to CF - Resources - Top 

Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.