Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Date function question

Re: Date function question

From: <yong321_at_yahoo.com>
Date: 2000/03/03
Message-ID: <89p6q6$d8$1@nnrp1.deja.com>#1/1

Abey,

I guess I don't understand you. You mean it's incorrect in case the person is not born but is predicted to be born some time later?

After I posted my message, I realized my query didn't really solve your problem because you also want to have month, not just year (i.e. a person born in 4/1998 is age 1 year plus 10 months, not 2 years). To do that, you probably have to do some calculation yourself:

After select to_char(sysdate,'yyyy')-to_char(dob,'yyyy') yr, you select to_char(sysdate,'mm')-to_char(dob,'mm') mon. If mon>=0, simply report yr||' years and '||mon||' months old', else, report yr-1||' years and '||12+mon||' months old'.

Yong Huang

In article <89ou11$iot$1_at_nntp3.atl.mindspring.net>,   "Abey Joseph" <abeyj_at_netzero.net> wrote:
> This statement would give me an age that will be incorrect if the
 date and
> month for DOB is > sysdate!
>
> <yong321_at_yahoo.com> wrote in message

 news:89os9l$nuj$1_at_nnrp1.deja.com...
> > select to_char(sysdate,'yyyy')-to_char(dob,'yyyy') age
> > from emp;
> >
> > Yong Huang

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Fri Mar 03 2000 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US