How can I calculate the number of work days between two dates in SQL Server?
Monday to Friday and it must be T-SQL.
(I'm a few points shy of commenting privileges)
If you decide to forgo the +1 day in CMS's elegant solution, note that if your start date and end date are in the same weekend, you get a negative answer. Ie., 2008/10/26 to 2008/10/26 returns -1.
my rather simplistic solution:
select @Result = (..CMS's answer..)
if (@Result < 0)
select @Result = 0
RETURN @Result
.. which also sets all erroneous posts with start date after end date to zero. Something you may or may not be looking for.