SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

khauskins
Starting Member

2 Posts

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

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!

sunitabeck
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

khauskins
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  
 New 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.05 seconds. Powered By: Snitz Forums 2000