0

Hi Friends ,

I got a row in my table like follows

date | Name | id
--------------------------
22-August | Ram | 15
14-July | Krish | 17
14_March | Anwar | 145
---------------------------

I want to sort this with date ie,

14-March
14-Jusy
22-August


Using both date and month ......
Please help me

Thanks in advance
Thank you for your valuable time
Rajeesh

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by d5e5
0

You should set up the "date" column as a true date field, not as a character field. Then you could sort by this field.

0

It is confusing to name a column 'date' because DATE is a datatype. The creator of the table should have created a DATE type column with a better name. If you have no choice but to try and sort this table without altering the design, try the following:

mysql> select * from test ORDER BY STR_TO_DATE(date, '%d-%M');
+-----------+-------+-----+
| date      | Name  | id  |
+-----------+-------+-----+
| 14_March  | Anwar | 145 | 
| 14-July   | Krish |  17 | 
| 22-August | Ram   |  15 | 
+-----------+-------+-----+
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.