Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: finding weeks between dates in oracle
jim agans wrote:
>
> what I need to do is get the number of weeks between 2 dates and turn
> it into a decimal for adding to a sum and then getting the avg for the
> number of records read.
>
> I have 2 dates ex: 01/27/2000 and 09/22/1999
> how do it get the number of weeks in between....ie: 12.4
> I will then add the 12.4 to (sum_field) and read another record
> and add 1 to a counter(rec_total)divide sum_field by records
> read(rec_count)
> say sum_field/ rec_count = 7.4 weeks
>
> I have looked at "between_months" but how do I convert it to
> weeks?
> thanks
> jim agans
Depends on your definition of 'weeks', but in the simplest case:
weeks = ( date1 - date2 ) / 7
hth
connor
-- ========================= Connor McDonald http://www.oracledba.co.uk "Some days you're the pigeon, some days you're the statue"Received on Sat Jun 14 2003 - 02:49:19 CDT