johnsmith153 Posted November 18, 2010 Share Posted November 18, 2010 A MySql database I am working with stores dates like 11/18/2010 (varchar type). Can I arrange this in order? Would be grest if they were timestamp, but they're not. Quote Link to comment https://forums.phpfreaks.com/topic/219070-order-by-mmddyyyy/ Share on other sites More sharing options...
jdavidbakr Posted November 18, 2010 Share Posted November 18, 2010 If you want to order by date you'll need to change the column to DATE. If you sort by that you'll get the order by whatever the sort collation is set to, which is most likely not the order you're looking for. Any reason it's in there as a VARCHAR? Quote Link to comment https://forums.phpfreaks.com/topic/219070-order-by-mmddyyyy/#findComment-1136369 Share on other sites More sharing options...
fenway Posted November 21, 2010 Share Posted November 21, 2010 You can cheat temporarily with STR_TO_DATE(), but that's a hack. Quote Link to comment https://forums.phpfreaks.com/topic/219070-order-by-mmddyyyy/#findComment-1137527 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.