Re: Calculate working days using stored procedure
Posted in 1998
This is a slightly difficult problem with many solutions. Here is one
possible (I haven't tested this so check everything for yourself):
If you create a table thus:
create table calendar(
caldate date,
workdayno integer);
primary key caldate
index on workdayno
and insert at least the dates that are working days with workdayno
starting on 1 for the first date that is a workday and increased by 1
for every following date that is also a workday, you can do as follows
for your particular calculation:
select caldate from calendar
where workdayno = (select workdayno + 10 from calendar where caldate =
mdy(6,27,1998))
For a more general calendar I would probably put in a few more fields
like a marker for hollidays and possibly others.
This table will not contain many rows even if you need dates for 10 or
20 years.
On Wed, 24 Jun 1998 22:36:22 GMT, sjsyau@my-dejanews.com wrote:
>Please help me here.
>
>Given:
>
>Today's date + Working Days
>Today's date - Working Days
>
>I need to find out the result in date format. The working days means to
>exclude weekends and holidays.
>
>Ex,
> 06-27-1998 + 10
>should = 07-10-1998
>
>Any hints?
>
>SJ
>sjsyau@yahoo.com
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/ Now offering spam-free web-based newsreading
Nils Myklebust
NM Data AS
Norway
E-mail: Nils.Myklebust@nmdata.com
FAQ at: http://www.iiug.org/techinfo/faq/faq_top.html
(Now with ODBC info under "Third party products".)