Hello,
When using this here I'm always getting the date of the 13th of current month.
I'm not sure why. Regaurdless how you look at it subtracting 3 business days
from the 18th would not equal the 13th. Any thoughts would be greatly
appreciated. Thanks.
'Procdt is the processing date
'Goto Batcave exits the sub
THREEBD18TH:
If Day(18) > pDays Then 'Is the day that it should be remitted already
past for this month? If so go to next month
fncDueDate = DateAdd("m", 1, Procdt) 'add one month
fncDueDate = Procdt
fncDueDate = DateSerial(Year(fncDueDate), Month([fncDueDate]), Day(18) + 1)
'set the date static
fncDueDate = UpBusDays3(fncDueDate, 3, False)
GoTo Batcave
'fncDueDate = UpBusDays3(DateSerial(Year(fncDueDate), Month([fncDueDate]),
Day(18) + 1), 3, False)
Else
fncDueDate = Procdt
fncDueDate = DateSerial(Year(fncDueDate), Month([fncDueDate]), Day(18) + 1)
'set the date static
fncDueDate = UpBusDays3(fncDueDate, 3, False)
End If
Function UpBusDays3(pStart As Date, _
pnum As Integer, _
Optional pAdd As Boolean = False) As Date
''*******************************************
'Purpose: Add or subtract business days
' from a date
'Coded by: raskew
'Inputs: +) ? UpBusDays3(#2/17/06#, 3, True)
' -) ? UpBusDays3(#2/22/06#, 3, False)
'Output: +) 2/22/06
' -) 2/17/06
'*******************************************
Dim dteHold As Date
Dim I As Integer
Dim n As Integer
dteHold = pStart
n = pnum
For I = 1 To n
If pAdd Then 'add days
dteHold = dteHold + IIF(Weekday(dteHold) > 5, 9 - Weekday(dteHold),
1)
Else 'subtract days
'this isn't working for Sunday
dteHold = dteHold - IIF(Weekday(dteHold) = 1 Or 7, 6, dteHold)
'dteHold = dteHold - IIF(Weekday(dteHold) < 3, Choose(Weekday
(dteHold), 2, 3), 1)
End If
Next I
UpBusDays3 = dteHold
End Function
Joker - 29 May 2007 21:25 GMT
Hello,
Would anyone have any ideas on this? I am still struggling on this. Thanks.