I am trying to get data form table using mysqli "Between" function. But it gives me wrong result i want to get data form "01-03-2017" to "30-03-2017". My database have only 2 values one is "21-03-2017" another is "22-03-2017". But my query return me 6 values including "February". I want only march values.
This is my Table (Id="INT", Name= "Varchar", Date="Varchar")
id | name | date
--------------------
1 | name1 | 01-02-2017
2 | name1 | 02-02-2017
3 | name1 | 03-02-2017
4 | name1 | 04-02-2017
5 | name1 | 05-02-2017
6 | name1 | 06-02-2017
7 | name1 | 07-02-2017
8 | name1 | 21-03-2017
9 | name1 | 22-03-2017
This is MYSQLI Query
SELECT * FROM `booking` WHERE `date` BETWEEN '01-03-2017' AND '30-03-2017'
Check here result. It gives me wrong reustl. enter image description here
SELECT * FROM `booking` WHERE CAST(`date` AS DATE) BETWEEN '01-03-2017' AND '30-03-2017'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.