Past Business Dates (Exclude Weekends & Holidays)

jkpats12

Registered User.
Local time
Today, 19:23
Joined
Jan 27, 2004
Messages
45
Hi everyone,

Looking for some assistance on setting up some code which would locate 2 prior business dates from today's date(e.g. today's date is 8/4, want code to pull in date 8/2)

Also this would need to exclude weekends & holidays (this is imperative to exclude these), if anyone can assist with this it would be greatly appreciated.

Thansk in advance
 
Code:
Public Function MinusWorkdays(dteStart As Date, intNumDays As Long) As Date

MinusWorkdays = dteStart
Do While intNumDays > 0
     MinusWorkdays = DateAdd("d", -1, MinusWorkdays)
     If Weekday(MinusWorkdays, vbMonday) <= 5 Then
'-- If you have a Holiday Table use the next IF instead!
'     If Weekday(MinusWorkdays, vbMonday) <= 5 And _
      IsNull(DLookup("[Holiday]", "tblHolidays", _
      "[HolDate] = #" & MinusWorkdays & "#")) Then
          intNumDays = intNumDays - 1
     End If
Loop
End Function
 
Thank you Rural Guy, I will give it a shot and get back to you with my results.
 
Thank you very much sir, this works beautifully !!!

Thanks again
 

Users who are viewing this thread

Back
Top Bottom