Re: Calculate working days using stored procedure
Posted in 1998
Hi SJ, I am sure there is no direct way to do this. The work around, can be many depending the one you prefer you can use any of the following : 1. write a sp and pass date, operator (+ or -), and integer, find out the resultant day Check if the day is sat or sun Again there can be many ways to do this : let i = (rt_date - '01/01/1900' ) / 7 ; let j = (rt_date - '01/01/1900' ) - ( i * 7 ) ; J = 5 for Saturday and J = 6 for Sunday if operator = + if day is sat, add 2 to result if day is sun, add 1 to result if operator = - if day is sat, subtract 1 from result if day is sun, subtract 2 from result 2. If you have more then sat and sun as holidays then you can have two options A. Store all the holidays in a table Do the date calculation. for + Keep adding one day to the result till the resultant date is not present in the holiday table. for - keep subtracting one day from the result till the resultant date is not present in the holiday table. B. Store all the working days in the table for addition Select min(work_date) from working_table where work_date < work_date - 10 I am sure all the above works. Regards, ____________________________________________________________ Sunil Thakkar (sunil0@hotmail.com) Informix DBA Last seen: Consulting at US-AirForce, Texas. _____________________________________________________________ There is always a simple way of solving complicated problems. ----Original Message Follows---- From: sjsyau@my-dejanews.com To: informix-list@iiug.org Subject: Calculate working days using stored procedure Date: Wed, 24 Jun 1998 22:36:22 GMT Reply-To: sjsyau@my-dejanews.com 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 ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com