Eiolon Posted December 6, 2007 Share Posted December 6, 2007 For some reason it is ordering alphabetically based on the name of the month not the actual date. I am using a MySQL datetime field. Query: // Query the database for participant information. $query_participants = "SELECT participant_id, participant_name, participant_phone, DATE_FORMAT(participant_added, '%M %e, %Y %l:%i %p') as convdate2, participant_age, participant_paid, participant_program FROM participants WHERE participant_program = ".$_GET['program_id']." ORDER BY convdate2 ASC"; $participants = mysql_query($query_participants) OR die ('Cannot retrieve participants.'); $row_participants = mysql_fetch_array($participants); Result: December 1, 2007 1:58 PM November 27, 2007 5:26 PM November 27, 2007 5:26 PM November 30, 2007 3:20 PM Quote Link to comment https://forums.phpfreaks.com/topic/80537-solved-not-properly-ordering-by-date/ Share on other sites More sharing options...
trq Posted December 6, 2007 Share Posted December 6, 2007 You'll want to use... ORDER BY participant_added as DATE_FORMAT returns a string. Quote Link to comment https://forums.phpfreaks.com/topic/80537-solved-not-properly-ordering-by-date/#findComment-408350 Share on other sites More sharing options...
Eiolon Posted December 6, 2007 Author Share Posted December 6, 2007 Ah, crap. I knew it was something simple. Quote Link to comment https://forums.phpfreaks.com/topic/80537-solved-not-properly-ordering-by-date/#findComment-408351 Share on other sites More sharing options...
revraz Posted December 6, 2007 Share Posted December 6, 2007 Yeah, I found that out the hard way too. I just decided to use Unix Timestamp for everything and do my formatting with PHP. Quote Link to comment https://forums.phpfreaks.com/topic/80537-solved-not-properly-ordering-by-date/#findComment-408359 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.