Wrox Programmer Forums
|
SQL Server 2005 General discussion of SQL Server *2005* version only.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2005 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 24th, 2007, 04:03 PM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default Calculate # of work days ?

I need to calculate the number of business work days between the date_insert and today.
This value will be re-calculated each Monday.
So, I'm guessing that the best way to do this will be a stored procedure.

Has any one else done this?
Any ideas?

Thanks,
Karen

 
Old May 24th, 2007, 04:11 PM
Wrox Author
 
Join Date: Oct 2005
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons
Default

I have no experience doing this, but this MSDN article should set you along the right path
http://msdn2.microsoft.com/en-us/library/aa224838(sql.80).aspx

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
Technical Editor for: Professional Search Engine Optimization with ASP.NET
http://www.wiley.com/WileyCDA/WileyT...470131470.html
================================================== =========
Why can't Programmers, program??
http://www.codinghorror.com/blog/archives/000781.html
================================================== =========
 
Old June 1st, 2007, 08:49 PM
Friend of Wrox
 
Join Date: Oct 2006
Posts: 475
Thanks: 0
Thanked 9 Times in 9 Posts
Default

This should help... doesn't take Holidays into account...

Code:
SELECT
   (DATEDIFF(dd, @StartDate, @EndDate) + 1)
  -(DATEDIFF(wk, @StartDate, @EndDate) * 2)
  -(CASE WHEN DATENAME(dw, @StartDate) = 'Sunday' THEN 1 ELSE 0 END)
  -(CASE WHEN DATENAME(dw, @EndDate) = 'Saturday' THEN 1 ELSE 0 END)


--Jeff Moden
 
Old June 9th, 2007, 09:11 PM
Authorized User
 
Join Date: Dec 2006
Posts: 70
Thanks: 0
Thanked 1 Time in 1 Post
Default

Thanks for the help.

I was told yesterday the client decided to do aging based on calendar days instead!

Thanks again.
Karen






Similar Threads
Thread Thread Starter Forum Replies Last Post
How to calculate a number of days between 2 date windy417 Pro JSP 1 July 20th, 2006 07:09 PM
Days in a Month jmss66 Classic ASP Basics 3 April 11th, 2005 05:57 PM
No of days anandham SQL Server 2000 2 March 21st, 2005 01:20 AM
Calculate Business Days - MS access 97 snoopy92211 Access VBA 0 October 13th, 2004 02:13 PM
How to calculate the work days beetwen two dates. andres_pm Javascript 1 October 7th, 2004 06:23 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.