We help IT Professionals succeed at work.

Calculate the days between two dates in SQL

I have a sql table with two dates and I want to run a query showing the two dates with a calculated field showing the difference in number of days between these two dates.  However the trick is I only want the calulated field to return the number of working days between the dates that is the number of Mondays to Fridays between to dates substracing all weekend days.
Comment
Watch Question

Software Architect
Top Expert 2005
Commented:
Guy Hengel [angelIII / a3]Billing Engineer
Most Valuable Expert 2014
Top Expert 2009

Commented:
usually you use a calendar table for this:
http://weblogs.sqlteam.com/dang/archive/2010/07/19/calendar-table-and-datetime-functions.aspx
http://sqlserver2000.databases.aspfaq.com/why-should-i-consider-using-an-auxiliary-calendar-table.html

with this, you just to a count(*) from the records from that table between the start and end date, skipping the records that are not "week-end" (or holiday)