why this query gives me the wrong output although I am trying to print data between '01-May-2022' and '30-May-2022';
why is this query giving me apr data?
CodePudding user response:
It appears that you are storing your dates as text. You should not be doing this, and the best long term fix is to make datee
a proper date column. As a short term fix, you may use STR_TO_DATE
:
SELECT datee
FROM customer_shopping_details_tbl
WHERE STR_TO_DATE(datee, '%d-%b-%Y') BETWEEN '2022-05-01' AND '2022-05-30';
CodePudding user response:
Good evening,
Maybe this could help:
SELECT login,datetime FROM log where datetime between
to_date(’01-jan-2004,’mm/dd/yyyy’) and
to_date(’21-jan-2004′,’mm/dd/yyy’)
order by datetime DESC;