brown2005 Posted March 5, 2007 Share Posted March 5, 2007 i have a field in a table birthdate and i have a function age(); if i use $sql = "SELECT brithdate, COUNT(*) AS birthdate_count FROM members;"; will echo out, say: birthdate 3 but really i want it to echo 19 3 how would I go about fitting in my age() function or would I need to have a field in the table for age, as I didnt want to do this as i would need to keep updating it, where as with a function it runs automatically... any help please? Link to comment https://forums.phpfreaks.com/topic/41343-birhtdate-to-age/ Share on other sites More sharing options...
HalfBrian Posted March 5, 2007 Share Posted March 5, 2007 Please include the table format of `members` And also, in your example 19 3 What is the 19? Link to comment https://forums.phpfreaks.com/topic/41343-birhtdate-to-age/#findComment-200325 Share on other sites More sharing options...
Barand Posted March 5, 2007 Share Posted March 5, 2007 You could do do something like SELECT FLOOR(DATEDIFF(CURDATE(), birthdate)/365) AS age, COUNT(*) as birthdate_count FROM members GROUP BY age Link to comment https://forums.phpfreaks.com/topic/41343-birhtdate-to-age/#findComment-200344 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.