Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: SCRIPT: Get age of person in Years, Months, Days.
"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.
|
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.
|
Regards
Michel Cadot
Received on Fri Feb 18 2005 - 11:06:14 CST