Forum Moderators: coopster
SELECT `ID` , UNIX_TIMESTAMP(CreationDate) AS CreationDate, `AccountType` , `username` , DATE_FORMAT(NOW(), '%Y') - DATE_FORMAT(age, '%Y') - (DATE_FORMAT(NOW(), '00-%m-%d') < DATE_FORMAT(age, '00-%m-%d')) AS age, `age` as DOB
FROM tablea
WHERE ID = '".$_SESSION['ID']."
LIMIT 1'"
or should I do it with php:
function calc_age($DOB) {
$age = (date("Y") - date("Y",$DOB));
if (mktime(0,0,0,date("m",$DOB),date("j",$DOB),date("Y")) <= time())
return $age;
else
return $age -1;
}
thanks
SELECT
ID,
UNIX_TIMESTAMP(CreationDate) AS CreationDate,
AccountType,
username,
(YEAR(NOW()) - YEAR(birthdate)) - (RIGHT(NOW(),5) < RIGHT(birthdate,5)) AS age
FROM tablea
WHERE ID = '".$_SESSION['ID']."'
LIMIT 1
;
SELECT
ID,
UNIX_TIMESTAMP(CreationDate) AS CreationDate,
AccountType,
username,
(YEAR(NOW()) - YEAR(birthdate)) - (RIGHT(NOW(),5) < RIGHT(DATE(birthdate),5)) AS age
FROM tablea
WHERE ID = '".$_SESSION['ID']."'
LIMIT 1
;