Quote:
Originally Posted by redwhiteandblue
MySQL (and PHP for that matter) does not magically recognize '2022-01-10' as a date. It's just a string with some numbers and hyphens in it. You can compare two strings but it's not the same as comparing dates. You have to tell it it's a date by casting it from "string" type to "date" type.
|
Mysql actually does - you don't have to cast it as a date. BETWEEN '2022-01-01' AND '2022-12-31' will work fine. It's possible it might not work if you have strict mode on but overall it does parse it by itself.