php - How to sort using month and day using mysql
I have a date in this format.
08 april 1989 02 December 1984 13 January 1986
I would like to sort the results using month and day ,which has column "dateofb" and i sorting is like
13 january 1986 08 april 1989 02 december 1984
I have used the below code which doesn't work fine ,
$sel = $db->query("select * from biography where dateofb >= (CURDATE() - INTERVAL 90 DAY) order by dateofb desc limit 0,3");
I would like to display the 3 sorted results coming 90days.
Is it possible to convert the
DATEcolumn type? This would allow you to do what you're looking for. The format you have now is invalid and would need to be converted via
STR_TO_DATE(dateofb, '%d %M %Y')
^- See how gross that looks? If your
DATEcolumn, you could just do:
^- which is your original query.
If your "dateofb" field is a DATE or DATETIME: