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); 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. Link to comment https://forums.phpfreaks.com/topic/232372-order-by-date/#findComment-1195383 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.