Hello people
I have Student Table (Name, gender, mm, dd, yyyy, level)
I want to do query to show student between age 20 to age 25
How I can do this
Hello people
I have Student Table (Name, gender, mm, dd, yyyy, level)
I want to do query to show student between age 20 to age 25
How I can do this
Why do you have mm, dd, yyyy fields when you can have a date field? If you simply had a date field for their DOB you could do this:
[PHP]
$stmt = $dbconn->prepare("
SELECT name, gender, birthday
FROM students
WHERE birthday BETWEEN :startdate AND :enddate
");
$statement->execute([
“:startdate” => ‘dd-mm-yyyy’,
“:enddate” => ‘dd-mm-yyyy’
]);
[/PHP]
scottlpool2003
How I can store the date in a date field and I want from user to enter his or she birthday as mm, dd, yyyy?
Can I do it with array?
This is what I use on one of my websites:
[PHP]
$startStamp = DateTime::createFromFormat(‘d/m/Y H:i:s’,’’ . $_POST[‘start’] . ‘’)->getTimestamp();
[/PHP]
You can find out more about createFromFormat here: http://php.net/manual/en/datetime.createfromformat.php