phpmady Posted April 10, 2011 Share Posted April 10, 2011 hi, I want to find the age from the date of birth, this is my sql.. select emp.E_ID as Code, emp.E_Name as Name, contry.Country_Name as Nationality, emp.E_UID as ID, empe.EE_Institution_Name as University, empe.EE_Degree as Degree, mm.Maj_Name as Specialization , expm.Exp_Name +' years' as Experience, emp.E_Email as Email, emp.E_Mobile as Mobile from major mm left join employee_education empe on empe.Maj_ID = mm.Maj_ID left join employee emp on emp.E_ID = empe.E_ID left join country contry on emp.E_Country = contry.Country_ID left join experience_yrs_master expm on emp.Exp_ID = expm.Exp_ID where 1 group by emp.E_ID my Birthdate field is E_Birthday.. Please Help me.. thanks, Link to comment https://forums.phpfreaks.com/topic/233257-selecting-age-from-date-field/ Share on other sites More sharing options...
phpmady Posted April 10, 2011 Author Share Posted April 10, 2011 this is the answer SELECT emp.E_ID as Code, emp.E_Name as Name, contry.Country_Name as Nationality, emp.E_UID as ID, DATE_FORMAT( FROM_DAYS( TO_DAYS( NOW( ) ) - TO_DAYS( `E_Birthdate` ) ) , '%Y' ) +0 AS Age, empe.EE_Institution_Name as University, empe.EE_Degree as Degree, mm.Maj_Name as Specialization , expm.Exp_Name +' years' as Experience, emp.E_Email as Email, emp.E_Mobile as Mobile, emp.CV_Resume as Resume from major mm left join employee_education empe on empe.Maj_ID = mm.Maj_ID left join employee emp on emp.E_ID = empe.E_ID left join country contry on emp.E_Country = contry.Country_ID left join experience_yrs_master expm on emp.Exp_ID = expm.Exp_ID hi, I want to find the age from the date of birth, this is my sql.. select emp.E_ID as Code, emp.E_Name as Name, contry.Country_Name as Nationality, emp.E_UID as ID, empe.EE_Institution_Name as University, empe.EE_Degree as Degree, mm.Maj_Name as Specialization , expm.Exp_Name +' years' as Experience, emp.E_Email as Email, emp.E_Mobile as Mobile from major mm left join employee_education empe on empe.Maj_ID = mm.Maj_ID left join employee emp on emp.E_ID = empe.E_ID left join country contry on emp.E_Country = contry.Country_ID left join experience_yrs_master expm on emp.Exp_ID = expm.Exp_ID where 1 group by emp.E_ID my Birthdate field is E_Birthday.. Please Help me.. thanks, Link to comment https://forums.phpfreaks.com/topic/233257-selecting-age-from-date-field/#findComment-1199607 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.