[dba-SQLServer] Holidays by Nation and State/Province/Canton/etc.

artful at rogers.com artful at rogers.com
Thu Jan 11 21:34:17 CST 2007


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





More information about the dba-SQLServer mailing list