php - How to select MYSQL Content with between Date
How can I display values from the database of the Stand column with the help of the Datum column between two dates?
I tried the following code, but no result:
$sqlAverage10 = "SELECT Stand FROM Aktienstand WHERE Symbol=:symbol AND Datum BETWEEN :startDate AND :endDate10";
if ($stmtAverage10 = $pdo->prepare($sqlAverage10)) {
$stmtAverage10->execute(array(
':symbol' => $kurs['Symbol'],
':startDate' => $startDate,
':endDate10' => $endDate10
));
//var_dump($kurs['Datum']);
//var_dump ($stmtAverage10);
//echo ($startDate = $kurs['Datum']);
$stmtAverage10New = $stmtAverage10->fetch(PDO::FETCH_ASSOC);
:symbol = test :startDate = 2021-10-09 :endDate = 2021-09-29
My table for e.g.:
https://i.stack.imgur.com/abEta.png
Answer
Solution:
That should work as long as your column is a date
or datetime
column.