Days remaining less weekends

Red6

Registered User.
Local time
Today, 13:04
Joined
Jan 9, 2003
Messages
28
I am sure I have seen this posted before but cannot find it.

There is a way of calculating the days remaining in a month less weekends.

Please point me in the right direction
Many thanks
 
Code:
Function CalcWkDays5(dteStartDate As Date) As Integer
'input: (from debug window) ? CalcWkDays5(#05/05/03#)
'output: 20
'NOTE:As written,this counts both start and end dates.

Dim n As Integer
Dim dteEndDate As Date

'calculate last day of month
dteEndDate = DateSerial(Year([dteStartDate]), Month([dteStartDate]) + 1, 0)
n = 0

Do While dteStartDate <= dteEndDate

   '17 in the following expression represents the numeric
   'days of week for Sunday(1) and Saturday (7)

   n = n + IIf(InStr("17", WeekDay(dteStartDate)) = 0, 1, 0)
   dteStartDate = dteStartDate + 1

Loop

CalcWkDays5 = n
End Function
 

Users who are viewing this thread

Back
Top Bottom