Home » SQL & PL/SQL » SQL & PL/SQL » Function (Working Days)
Function [message #273360] Wed, 10 October 2007 02:33 Go to next message
kr_arvind
Messages: 85
Registered: April 2006
Location: Delhi
Member
Hi,

How to calculate the working days except Saturday & sunday between the date, please help me through function.


Regards,
Arvind
Re: Function [message #273363 is a reply to message #273360] Wed, 10 October 2007 02:42 Go to previous messageGo to next message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
There are two approaches you can take.

1) Use a row generator to step through all the dates between the two dates, and count the number of Saturdays and Sundays that you get

2) Count the number of days between the two dates. Knock 2 off this total for every full 7 days, and then adjust the total if the start or end dates are on a weekend.


Notes:
1) is easier to code, but will run more slowly
2) Is trickier to design, but quicker.
Re: Function [message #273367 is a reply to message #273360] Wed, 10 October 2007 02:51 Go to previous messageGo to next message
Michel Cadot
Messages: 64132
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Read the thread Counting the number of business days between 2 dates on AskTom.

Regards
Michel
Re: Function [message #273433 is a reply to message #273360] Wed, 10 October 2007 08:01 Go to previous message
joy_division
Messages: 4642
Registered: February 2005
Location: East Coast USA
Senior Member
Congratulations on learning how to use relevant titles. Why even bother putting a title at all? You might as well just leave it blank.
Previous Topic: Select query in procedure!
Next Topic: Combination required from code
Goto Forum:
  


Current Time: Wed Dec 07 20:35:58 CST 2016

Total time taken to generate the page: 0.06782 seconds