troubleshooting Question

Skip weekends when calculating days between 2 given dates - SQL

Avatar of CodeWrangler
CodeWrangler asked on
Microsoft SQL Server 2005Microsoft SQL Server 2008
6 Comments1 Solution662 ViewsLast Modified:
Hello,

I have 2 dates, @date1 and @date2, can someone show me a way to calculate weekdays only between the two dates without using a calendar table using SQL
Here are some conditions:
1. If the start or end date falls on a weekend, skip those days. eg: 9-18-10 (sat) to 9-25-10 (sun) should return 5
2. If both start and end date are on the same weekend, return 0

Thanks in advance.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 6 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros