Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 DATEDIFF calculation that excludes Sundays
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 11/15/2012 :  12:18:13  Show Profile  Reply with Quote

I need to get the difference in days between two dates without counting Sundays. Can this be done with DATEDIFF or is there another way to do it?

Any help would be greatly appreciated! Thanks!

Flowing Fount of Yak Knowledge

5155 Posts

Posted - 11/15/2012 :  12:27:18  Show Profile  Reply with Quote
You can do this:
DATEDIFF(dd,startDate,EndDate) - DATEDIFF(wk,startDate,endDate);
It should work correctly regardless of your datefirst setting, but check the boundary conditions (when start date or enddate is on a weekend) to see if it is off by 1 and make adjustments as necessary.
Go to Top of Page

Starting Member

2 Posts

Posted - 11/16/2012 :  11:56:06  Show Profile  Reply with Quote
Looks like that worked - thank you!
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000