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: Frank van Bortel <fvanbortel_at_netscape.net>
Date: Mon, 21 Feb 2005 10:44:22 +0100
Message-ID: <cvcado$iit$1@news3.zwoll1.ov.home.nl>


Michel Cadot wrote:
> "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
>
>

April, 7th is *not* 300+ days into the year, but day 97.

-- 
Regards,
Frank van Bortel
Received on Mon Feb 21 2005 - 03:44:22 CST

Original text of this message

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