datoshway Posted April 1, 2011 Share Posted April 1, 2011 Have a date field with a mysql date format that is B d, Y Can't seem to get my query to sort correctly. See below. Thanks in advance. $strQuery = "SELECT * FROM tblVolunteer ORDER BY DATE_FORMAT( `strDate`, '%B%d,%Y' ) DESC"; $queryGetVol = db_query($strQuery); Quote Link to comment https://forums.phpfreaks.com/topic/232372-order-by-date/ Share on other sites More sharing options...
PFMaBiSmAd Posted April 1, 2011 Share Posted April 1, 2011 Use - ORDER BY strDate The YYYY-MM-DD format can be sorted because the fields making it up are left-to-right, most-significant-digits (year) to least-significant-digits (day). Your B d, Y formatted value cannot be sorted. Quote Link to comment https://forums.phpfreaks.com/topic/232372-order-by-date/#findComment-1195383 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.