Your use of STR_TO_DATE
is correct, but your date literals are off. Fix them, and your query should work:
SELECT *
FROM table_name
WHERE STR_TO_DATE(datetime,'%H:%i:%S %m/%d/%y') >= '2021-01-14' AND
STR_TO_DATE(datetime,'%H:%i:%S %m/%d/%y') < '2021-01-15';
The above assumes that you want records occurring on 14th January, 2021, proper. Note that we don't need to even include the H:M:S components and can just use date literals.
It would be best to make your datetime
column a proper datetime type column, rather than text. This would avoid the need to use STR_TO_DATE
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…