How old are you?
I just come back from holiday, I am quite busy at the moment. Here is a tiny function to get the age
trunc((to_char(sysdate,'YYYYMMDD')-to_char(birthdate,'YYYYMMDD'))/10000)
it is much safer than add_months, because add_months do some conversion at the end of the month, and I would never accept to wait until Feb 29th, 2008 (28-2-1990 + 18*12 months) to be 18 if I were born Feb 28th, 1990.
trunc((to_char(sysdate,'YYYYMMDD')-to_char(birthdate,'YYYYMMDD'))/10000)
it is much safer than add_months, because add_months do some conversion at the end of the month, and I would never accept to wait until Feb 29th, 2008 (28-2-1990 + 18*12 months) to be 18 if I were born Feb 28th, 1990.
1 Comments:
oh greate!!
def birthdate = to_date('2000/02/29','yyyy/mm/dd')
def sys_date = to_date('2003/02/28','yyyy/mm/dd')
select
trunc((to_char(&sys_date,'YYYYMMDD')-to_char(&birthdate,'YYYYMMDD'))/10000) as age from dual;
def sys_date = to_date('2003/03/01','yyyy/mm/dd')
select
trunc((to_char(&sys_date,'YYYYMMDD')-to_char(&birthdate,'YYYYMMDD'))/10000) as age from dual;
Post a Comment
<< Home