How do I retrieve all 60 years old above using birth_date in PHP PDO?Ask a question
I want to display all the customer where the age is 60 years old above by using the birth_date. The type of bith_date is date. This is the format of the birth_date-> 1999-03-12. Can somebody help me with my problem?
$sql = "SELECT * FROM `tbl_beneficiary` INNER JOIN tbl_barangay ON tbl_beneficiary.barangay_id = tbl_barangay.barangay_id WHERE tbl_beneficiary.is_active = 'No' AND (DATEDIFF(NOW(), tbl_beneficiary.birth_date) <= 60) ORDER BY tbl_beneficiary.beneficiary_id";
I think this must work as you expect
$sql = "SELECT * FROM tbl_beneficiary INNER JOIN tbl_barangay ON
tbl_beneficiary.barangay_id = tbl_barangay.barangay_id WHERE
tbl_beneficiary.is_active = 'No' AND (DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), tbl_beneficiary.birth_date)), "%Y") >= 60) ORDER BY
- 1How to remove all local git branches that have been removed from origin
- 2How to move logging from PHP-FPM to Nginx
- 0Where to store all the huge information in blockchain-based projects ?
- 0using namespace std is bad
- 1How to disable php error reporting on production server
- 0C++: delete single object using delete
- 0Iterate over tokens using std::regex
- 0How to provide command line arguments using gdb within a bash script
- 0C++: avoid 'using namespace'
- 0typedef vs using in C++11
- 0How to unsubscribe from all observables in one component at once in Angular