Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DateDiff Limitation 1

Status
Not open for further replies.

Browner

Programmer
Mar 31, 2000
3
IE
I am trying to find a way of getting the number of "working" days (M-F) between two dates. I don't think I can do this with DateDiff. Is there any other function of method of doing this? Can you write your own functions in SQLServer? I would appreciate any advice.
 
You can get the result from date diff also. You just find&nbsp;&nbsp;no. of days&nbsp;&nbsp;between the two dates. Find the day of two dates. Calcualate no. of weeks and multiply it by 2. Then subtract it from no. of days. <br><br>Does this satisfy you ?<br>Thanx<br>Siddhartha Singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A>
 
You can get the result from date diff also. You just find&nbsp;&nbsp;no. of days&nbsp;&nbsp;between the two dates. Find the day of two dates. Calcualate no. of weeks and multiply it by 2. Then subtract it from no. of days. <br><br>Does this satisfy you ?<br>Thanx<br>Siddhartha Singh<br><A HREF="mailto:ssingh@aztecsoft.com">ssingh@aztecsoft.com</A>
 
If you wanted to exclude public holidays as well then you might have problems. I answered a similar question in this forum last week that gave a solution by creating a date lookup table.<br><br>However, if you want rough M-F do as Siddharta says, a function is far easier to manage. Although you should be careful if the start and end day fall on a Saturday or Sunday as you may be out by one day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top