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

Home -> Community -> Usenet -> c.d.o.misc -> Re: SCRIPT: Get age of person in Years, Months, Days.

Re: SCRIPT: Get age of person in Years, Months, Days.

From: Michel Cadot <micadot{at}altern{dot}org>
Date: Fri, 18 Feb 2005 18:06:14 +0100
Message-ID: <42162057$0$15790$636a15ce@news.free.fr>

"Craig & Co." <crb_at_amsa.gov.au> a écrit dans le message de news:42151b79$0$57510$c30e37c6_at_ken-reader.news.telstra.net...
| "Michel Cadot" <micadot{at}altern{dot}org> wrote in message
| news:42142cbb$0$10013$626a14ce_at_news.free.fr...
| >
| >
| > Why don't use Oracle built-in functions?
| >
| > For date_of_date enter in DD/MM/YYYY format:
| >
| > select
| trunc(months_between(sysdate,to_date('&&date_of_birth','MM/DD/YYYY'))/12)
| > || ' years ' ||
| > mod(trunc(months_between(sysdate,
| to_date('&&date_of_birth','MM/DD/YYYY'))),12)
| > || ' months ' ||
| > trunc(sysdate
| > - add_months(to_date('&&date_of_birth','MM/DD/YYYY'),
| > months_between(sysdate,
| to_date('&&date_of_birth','MM/DD/YYYY'))))
| > || ' days' "Year_Month_Day"
| > from dual;
| >
| > Regards
| > Michel Cadot
| >
| >
| Thanks for that. That's a lot neater for the Years and Months, however, the
| days is wrong.

|

| Using my birthday - 07-Apr-1975 - It comes up with 29 years 10 months and 10
| days.
| The Days should at least be 300+.

I don't understand "300+": number of days is always between 1 and number of days in the current month minus 1.
This is the number of days you have to add to your 29 years and 10 months to get back to your birth day.

| Hence the huge last statement in the program. I do like what you've done
| with the Years and Months though
| and will change my program accordingly.

|

| Cheers
| Craig.

|

Regards
Michel Cadot Received on Fri Feb 18 2005 - 11:06:14 CST

Original text of this message

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