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: Calculate Business Days

Re: Calculate Business Days

From: Connor McDonald <mcdonald.connor.cs_at_bhp.com.au>
Date: Mon, 08 Feb 1999 18:20:11 +0800
Message-ID: <36BEBA5B.4316@bhp.com.au>


scottja_at_lci.com wrote:
>
> I was wondering if anyone knew of an easy way to calaculate the number of
> business days (M-F) between to datse in Oracle.
>
> Oracle currenty returns a NUMBER value when subtracting two dates but I need
> to expand this to only count the business days between two dates and still
> return a NUMBER value.
>
> I believe this will require me to create an Oracle PL/SQL function which can
> be used to evaluate the difference of two dates in terms of business days but
> I am not sure what this algorithm looks like.
>
> ANY HELP
>
> Thanks in advance
>
> John
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own

Untested but I hope you get the idea........

function bus_days ( p_start date, p_end date) return number is begin
  return
    trunc((trunc(p_end,'DAY') -
    trunc(p_start,'DAY')) * 5/7 +
    (p_end - trunc(p_end,'DAY')) -
    (p_start - trunc(p_start,'DAY')));
end;

--



Connor McDonald
BHP Information Technology
Perth, Western Australia
"Never wrestle a pig - you both get dirty and the pig likes it..." Received on Mon Feb 08 1999 - 04:20:11 CST

Original text of this message

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