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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Working with dates not including weekends

Status
Not open for further replies.

St0rm

MIS
Oct 19, 2000
23
GB
I'm try to cal the number of working days X person will have off if they are away from say from 19/06/2000 until 31/09/200 (DD/MM/YYYY)what the problem is that it includes weekend so shows 12 days when it should be 8 [sig][/sig]
 
Well just subtract 2 days out for Sat. and Sun. for every week.
Easier said than done.
you will have to use VBA of course and get the Weeknum of the starting week and the ending week and multiply that number by 2

Week_Num = format(Date,"WW")
this will ge the week number for you
[sig]<p>DougP, MCP<br><a href=mailto: dposton@universal1.com> dposton@universal1.com</a><br><a href= > </a><br> Ask me how Bar-codes can help you be more productive.[/sig]
 
not quit sure I understand, If the date was not over a week end then it would still -2. or I'm i missing something their [sig][/sig]
 
Here is a function that I wrote that should work:

Public Function numofdays(startdate As Date, enddate As Date) As Integer
If WeekDay(startdate) <> 1 And WeekDay(startdate) <> 7 Then
numofdays = 1
Else
numofdays = 0
End If
Do Until startdate = enddate
startdate = startdate + 1
If WeekDay(startdate) <> 1 And WeekDay(startdate) <> 7 Then
numofdays = numofdays + 1
End If
Loop
End Function

Hope this helps! [sig]<p>Mike Rohde<br><a href=mailto:rohdem@marshallengines.com>rohdem@marshallengines.com</a><br>[/sig]
 
Well,

It gets a little more complicated. How are you going to handle holidays within the period? You need to build a table of holidays, then process the period startdate/enddate to determine that each date is a holiday/ weenend or regular workday. Count the workdays. This has been discussed extensively in the forum(s). Do a search on the word &quot;Holiday&quot;. I, along with several others, have posted more or less complete soloutions to this question.

[sig]<p>MichaelRed<br><a href=mailto:mred@duvallgroup.com>mred@duvallgroup.com</a><br>There is never time to do it right but there is always time to do it over[/sig]
 
Inspired by yet another dates between question, I have posted a soloution in the FAQ. Go to the FAQ and search for &quot;workdays&quot;.

[sig]<p>MichaelRed<br><a href=mailto:mred@duvallgroup.com>mred@duvallgroup.com</a><br>There is never time to do it right but there is always time to do it over[/sig]
 
thanks all I will go look now :) [sig][/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top