In the database, the date is stored in the text field, in the format of the form: 17.07.2016
I do a sample:
SELECT COUNT(`sms_send_exam`) FROM cartoteka WHERE `date_exam` BETWEEN '01.07.2000' AND '30.07.2025' I get 18 (actually)
When I do this:
SELECT COUNT(`sms_send_exam`) FROM cartoteka WHERE `date_exam` BETWEEN '29.07.2000' AND '30.07.2025' I’m already getting 11 (!), This is an incorrect result.
Or for BETWEEN need a certain data format, type?
Addition. I tried the request
SELECT COUNT(`sms_send_exam`) FROM cartoteka WHERE `date_exam` BETWEEN STR_TO_DATE('01.07.2000', '%d.%m.%Y') AND STR_TO_DATE('30.07.2025', '%d.%m.%Y') It did not help either. And for some reason gives 9 (!)
Supplement_2 (!)
But such an option, through LIKE ( checked - working ), is it scary or normal?
$sms_counter_month = mysql_query ( "SELECT COUNT(`sms_send_exam`) FROM ".$userstable." WHERE `date_exam` LIKE '%".$month.".".$year."'", $db);
WHERE STR_TO_DATE('date_exam', '%d.%m.%Y') BETWEEN STR_TO_DATE('01.07.2000', '%d.%m.%Y') AND STR_TO_DATE('30.07.2025', '%d.%m.%Y')? (only correct quotes on date_exam put) - Batanichek