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]
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]
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 "Holiday". 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 "workdays".
[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]
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.