Hi,

I currently am calculating the age based on Date of Birth from the database.

However I am told that I cannot search an AS on my recordset query from mysql database with PHP.

Is this true and if so how can i search the age calculated from their Date of birth?

Currently i have used this to calculate the age which works but i cannot search:


SELECT DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(dob, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(dob, '00-%m-%d')) AS age


many thanks

SELECT * FROM (SELECT DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(dob, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(dob, '00-%m-%d')) AS age FROM table) WHERE age > 10
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.