0

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

1

1 Answer 1

0
SELECT * FROM `booking` WHERE CAST(`date` AS DATE) BETWEEN '01-03-2017' AND '30-03-2017'
Sign up to request clarification or add additional context in comments.

1 Comment

SELECT * FROM booking` WHERE CAST(date AS DATE) BETWEEN '2017-03-01' AND '2017-03-30'` You are type casting here.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.