我无法显示在DATE格式化的生日[复制]

This question already has an answer here:

i want to display the customers information who was born between 1980 and 1990. And i tried this but it doesnt work. Can u please help me?

This is my php codes.

<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "company";


$conn = new mysqli($servername, $username, $password, $dbname)
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}

$sql = "SELECT * FROM musteri WHERE dogumtarih<'1980-01-01' and 
dogumtarih>'1990-01-01'";
$result = $conn->query($sql);
?>
</div>

Please change your sql between query as per below solutions:

$sql = "SELECT *
FROM musteri
WHERE (dogumtarih BETWEEN '1980-01-01' AND '1990-01-01')";

You can find record between two dates.

Hope This Works for you.

As per my comment you should use between in query like this

SELECT * FROM musteri WHERE (dogumtarih BETWEEN '1980-01-01' AND '1990-01-01')

for more information about comparison operators (Manual)

Your code is right but there is a logic error there

$sql = "SELECT * FROM musteri WHERE dogumtarih>'1980-01-01' and 
dogumtarih<'1990-01-01'";

you want the birthday to be after 1980 and before 1990 so this should work fine for you. You just confused the comparison operators.