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: oracle dates calculations

Re: oracle dates calculations

From: DangerMouse <nospam_at_nospam.com>
Date: Fri, 27 Jun 2003 17:47:59 +0100
Message-ID: <3z_Ka.119$Ls.1551@newsfep4-glfd.server.ntli.net>


"Eric Parker" <eric.parker.spamless_at_virgin.net> wrote in message news:duZKa.2173$MO2.2161_at_newsfep4-winn.server.ntli.net...
>
> "Jim Kennedy" <kennedy-downwithspammersfamily_at_attbi.com> wrote in message
> news:zAYKa.33045$Ab2.58464_at_sccrnsc01...
> > 1. dates are not strings. dates are displayed and that is what you are
> > seeing. Subtract the date of birth and today (sysdate) and if the
> > difference is >= 18 * 365 then the individual is 18.
> > Jim
> > "jim agans" <jwagans_at_yahoo.com> wrote in message
> > news:82659da6.0306270629.68eee0cd_at_posting.google.com...
> > > I have a date of birth.....'MMDDYYYY' What I need to do is find out if
> > > the individual is 18 years old on this date.
> > > How can I do it ...any help someone?
> > >
> > > thanks
> > > jim
> >
> >
>
> Jim(s)
>
> There will be inaccuracies due to leap years with 18*365.
> I would try something based on
> add_months(sysdate, -12*18).
> You could still have problems with leap years though.
>
> HTH
>
> eric
>
>

Just use months_between and divide by 12 to get the number of years. Oracle handles the leap years.

Regards
DM Received on Fri Jun 27 2003 - 11:47:59 CDT

Original text of this message

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