ed01 Posted November 21, 2011 Share Posted November 21, 2011 What I'm trying to do is the following: Capture the latest date from any record in the table. Use that date to create a query to display all records of only that date. Here's what I have so far... SELECT hometeam, weekdate,day FROM sched_games WHERE day='Saturday' ORDER BY 'weekdate' DESC OUTPUT IS: hometeam weekdate day Euro 11/19/2011 Saturday Crusaders 11/19/2011 Saturday Cobras 11/26/2011 Saturday Titans 11/26/2011 Saturday Porto 9/24/2011 Saturday Titans 9/24/2011 Saturday Porto 9/15/2012 Saturday As you can see, the records are not being sorted by the weekdate. Seems like I need to convert the values in the weekdate column so that mysql recognizes them as dates first, and then maybe the sorting will work? Any help would be much appreciated. Thanks! Ed Quote Link to comment Share on other sites More sharing options...
mikosiko Posted November 21, 2011 Share Posted November 21, 2011 you are trying to order by the string ('weekdate') instead of the column weekdate and no reason to store the `day` in your table... day can be determined from your weekdate column http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_dayname Quote Link to comment 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.