Dan Waters
dwaters at usinternet.com
Fri Jan 12 09:17:16 CST 2007
Hi Arthur! This is my method: Have a permanent table that contains Holidays. Because each company has their own Holiday schedule, they will need to be able to populate this. 1) Calculate days between dates. 2) Subtract weekend days. 3) Subtract any Holidays that fall between the two dates. That's it! Dan Waters -----Original Message----- Subject: [dba-SQLServer] Holidays by Nation and State/Province/Canton/etc. One assumes that BusinessDaysBetween (@d1, @d2) observes the Holidays table and also ignores Saturday and Sunday (which admittedly could be wrong, but let's at first keep it simple). So: Inputs are 01-01-2007 and 02-28-2007. Assume that Saturday and Sunday are not business days. (This subject to revision, but later.) Assume that there are two holidays in January, the 16th and the 25th (chosen arbitrarily, I grant you, although I made sure they weren't Saturday or Sunday, else the exercise would be pointless). Algorithm: Build a temp table consisting of the dates between x and y. Subtract the dates existing in our holidays table. Subtract the dates describing our weekends. Sum the remaining days. Return the count. Holes in the algorithm? Please point them out before I cast this in stone. TIA, Arthur