Monday, 15 July 2013

oracle - Find year of birth from given age in sql -



oracle - Find year of birth from given age in sql -

can help me problem, know must utilize sysdate. illustration have entity employee atributes emp.id , age.

if supply add_months negative number subtracts many months given date. multiplying age -12 gives number of months need subtract current date derive approximate birthday.

select emp.id , to_char( add_months(sysdate, (emp.age*-12)) , 'yyyy') year_of_birth employee emp;

sql oracle date-arithmetic

No comments:

Post a Comment