| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> c.d.o.server -> Re: Calculate Business Days
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;
--
![]() |
![]() |