dbTalk Databases Forums  

Caculating "business days" in Oracle

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Caculating "business days" in Oracle in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
bbcrock@gmail.com
 
Posts: n/a

Default Caculating "business days" in Oracle - 05-19-2005 , 01:52 PM






My solution to calculating the number of business days using Oracle 8i
is to create a table with holidays and run some kind of calculation
like so:

select count(*)
from ( select rownum rnum
from all_objects
where rownum <= to_date('&1') - to_date('&2')+1 )
where to_char( to_date('&2')+rnum-1, 'DY' )
not in ( 'SAT', 'SUN' )
and not exists
( select null from table_of_holidays where no_work_day =
trunc(to_date('&2')+rnum-1) )
/

If anyone knows of an easier solution that doesn't require a separate
holiday table, let me know.

thanks,

Don


Reply With Quote
  #2  
Old   
Gerard H. Pille
 
Posts: n/a

Default Re: Caculating "business days" in Oracle - 05-19-2005 , 02:42 PM






bbcrock (AT) gmail (DOT) com wrote:
Quote:
My solution to calculating the number of business days using Oracle 8i
is to create a table with holidays and run some kind of calculation
like so:

select count(*)
from ( select rownum rnum
from all_objects
where rownum <= to_date('&1') - to_date('&2')+1 )
where to_char( to_date('&2')+rnum-1, 'DY' )
not in ( 'SAT', 'SUN' )
and not exists
( select null from table_of_holidays where no_work_day =
trunc(to_date('&2')+rnum-1) )
/

If anyone knows of an easier solution that doesn't require a separate
holiday table, let me know.

thanks,

Don

Not easier, but a hell of a lot faster (without using that foolish all_object),
but you'll still need the holiday table though.

Search Metalink for "workdays", I've posted it there.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.