DATE is not executing in PDO SQL

  date, fetch, pdo, php, sql

I am creating the fetch query from the database with date wise but it not working..
My SQL is –

$date = "2020-09-20";

$stmt = $con->prepare("SELECT * FROM `table` WHERE `inv_date` = :date AND `name` = :channel");
$stmt->execute(array(':date' => $date, ':channel' => "FLIPKART"));
if ($stmt->rowCount() > 0) {
   //do something
} else {
   echo "not found";
   exit();
}

Output: not found

but when I try to do like this –

SELECT * FROM `table` WHERE `inv_date` = '2020-09-20' AND `name` = :channel

then, it’s working..
I also tried with this also as below –

 SELECT * FROM `table` WHERE DATE(`inv_date`) = :date AND `name` = :channel

but, it’s not working…

I do not understand why this is happening, please tell me the error wherefrom it comes from and how to fix this issue…

In the database, inv_date is in DATE Type.

Please help me…

Source: Ask PHP

LEAVE A COMMENT