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 to exclude weekends
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

22 Posts

Posted - 02/05/2013 :  18:03:34  Show Profile  Reply with Quote
Is it possible to calculate difference in days between dates that exclude weekends, then calculate 8 hour day by hourly rate eg

start date: 28/06/2012 end date: 25/07/2012. Actual difference in days is 27, but remove the weekends (8 days) = 19 days. The actual duration in hours between start and end dates = 648 but should be between 7.00am - 3.00pm (8 hours). Hourly rate = $5.00.

End result should be: 19 days x 8 hours = 152 hours x $5.00 = $760.00

Any help would be much appreciated. Thanks

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 02/05/2013 :  18:57:36  Show Profile  Reply with Quote
5.00*8*( DATEDIFF(dd,'20120628','20120725')-2*DATEDIFF(wk,'20120628','20120725') )
Go to Top of Page

Starting Member

22 Posts

Posted - 02/12/2013 :  22:20:51  Show Profile  Reply with Quote
Thanks James - this is great,much appreciated! Apology for delay.
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 02/13/2013 :  04:48:47  Show Profile  Reply with Quote

SQL Server MVP

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