Reputation: 375
SELECT * FROM `customers` where warranty_end BETWEEN '01/12/2017' AND '31/12/2017'
the above one is my query, in warranty_end
column content is 30/12/2018
.
But the query resulting Row From Database.
Upvotes: 0
Views: 206
Reputation: 520928
It looks like your warranty_end
column is text, and furthermore you are storing your dates there is a non ISO format. One workaround here would be to convert the text dates into actual dates using STR_TO_DATE
:
SELECT *
FROM customers
WHERE STR_TO_DATE(warranty_end, '%d/%m/%Y') BETWEEN '2017-12-01' AND '2017-12-31';
Note here that the BETWEEN
clause in fact uses ISO date literals.
Moving forward a much better option would be to store your warranty end dates in a date column, e.g. datetime
.
Upvotes: 2