PHP MySQL Where Clause with DATE_FORMAT Query Example

Feb 09, 2022 . Admin

Hello Friends,

I am going to explain you example of PHP where clause with DATE_FORMAT query example. You will learn how to PHP where condition date format. I would like date format in PHP where query. This article will give you simple example of date format in PHP query where clause.

We will use get search how to use date in where clause in PHP. You can understand a concept of search date format in where clause PHP. So, we can illustrate the date format in where clause PHP. I explained simply about PHP using date in where clause.

You can see both example of how to search PHP using date in where clause.

Table: user_payments

So, let's see bellow solution:


$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "db_php";

// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);

$sql = "SELECT 
            DATE_FORMAT(payment_date,'%m/%d/%Y') as payment_date, 
        FROM `user_payments`
            WHERE DATE_FORMAT(payment_date,'%m/%d/%Y') = '01/04/2022'";

$result = $conn->query($sql);

while ($row = $result->fetch_assoc()) {
    echo '<pre>';


    [id] => 4
    [payment_date] => 01/04/2022
    [charge] => 10
    [id] => 5
    [payment_date] => 01/04/2022
    [charge] => 66
It will help you...