I have a MYSQL table with field name “date” in the formate “dd/mm”;
I need to query results from 20/06 to 22/06 (3 days data), this is how I am trying to do it.
mysql> SELECT * FROM `wtt` WHERE date BETWEEN '20/06' AND '22/06';
But MYSQL is also selecting the dates 22/04, 22/05 and other entries.
Is there MYSQL query which will fetch me the right answer without the need to change the format in which I have already stored the information in the MYSQL table?
Thank you all in advance!
You should convert the dates to MySQL date types and then compare them.
You can convert the dates like this:
or simply
for year 0000 if it doesn’t matter.
Storing dates as strings has brought this problem on you. You should always use DATE type for storing dates.