I need to select (count) rows with a specific date formatted by YEAR-MONTH-DAY.
i try
$date = $_GET['date'];
// requete qui recupere les evenements
$result = "SELECT COUNT(*) FROM evenement WHERE STR_TO_DATE(start, '%Y-%m-%d') = $date";
// connexion a la base de donnees
try {
$bdd = new PDO('mysql:host=;dbname=', '', '');
} catch(Exception $e) {
exit('Impossible de se connecter a la base de donnees.');
}
$sth = $bdd->query($result);
echo json_encode($sth->fetchColumn());
where date variable is a date with that format. i want to count rows and return the number of rows with that date.
i also try
$result = "SELECT COUNT(*) FROM evenement WHERE DATE_FORMAT(start, '%Y-%m-%d') = $date";
and
$result = "SELECT COUNT(*) FROM evenement WHERE DATE_FORMAT(DATE(start), '%Y-%m-%d') = $date";
but nothing works
any ideas?
Thanks
$dateis?