suttercain Posted November 22, 2007 Share Posted November 22, 2007 Hi guys, I think the title asks the question I am seeking an answer for. The database stores dates in a 1/5/1995 format (month/day/year) Can I have the results ORDER BY coverdate? Thanks, SC Link to comment https://forums.phpfreaks.com/topic/78444-solved-possible-to-order-mysql-results-by-this-type-of-date-format-311999/ Share on other sites More sharing options...
snk Posted November 22, 2007 Share Posted November 22, 2007 of course you can, if you want to reverse the order of result use the DESC at the end of your query e.g ..ORDER by f_date DESC; Link to comment https://forums.phpfreaks.com/topic/78444-solved-possible-to-order-mysql-results-by-this-type-of-date-format-311999/#findComment-396970 Share on other sites More sharing options...
suttercain Posted November 22, 2007 Author Share Posted November 22, 2007 I got it... $query = mysql_query("SELECT *, STR_TO_DATE(cover_date,'%d/%m/%Y') as Mydate FROM comics WHERE title = '".mysql_real_escape_string($search)."' AND type ='Comic Book' ORDER BY Mydate") or die(mysql_error()); Link to comment https://forums.phpfreaks.com/topic/78444-solved-possible-to-order-mysql-results-by-this-type-of-date-format-311999/#findComment-396976 Share on other sites More sharing options...
snk Posted November 22, 2007 Share Posted November 22, 2007 ouchhh ok, sorry i thought you wanted to order the data... thanks for replying the solution Link to comment https://forums.phpfreaks.com/topic/78444-solved-possible-to-order-mysql-results-by-this-type-of-date-format-311999/#findComment-396984 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.