Adding workdays to a date

C

cherrieate

Hi,

I need to add a specific number of dates to a specific date. I'm fine
when I'm using the DateAdd() function. I'm able to add days, weeks,
months and even years. But this time I need to add only workdays. I
need to be able to eliminate weekends and holidays. I can do it in
access using the Networkdays() function, but I can't seem to find a
way to do it in Access. I have MS Office 2003. Could somebody PLEASE
help me.

Thanks,
Cherrie
 
R

ruralguy via AccessMonster.com

Here's a function you can use:
Public Function PlusWorkdays(dteStart As Date, intNumDays As Long) As Date

PlusWorkdays = dteStart
Do While intNumDays > 0
PlusWorkdays = DateAdd("d", 1, PlusWorkdays)
If Weekday(PlusWorkdays, vbMonday) <= 5 Then
'-- If you have a Holiday Table use the next IF instead!
' If Weekday(PlusWorkdays, vbMonday) <= 5 And _
IsNull(DLookup("[Holiday]", "tblHolidays", _
"[HolDate] = " & Format(PlusWorkdays, "\#mm\/dd\/yyyy\#;;;\N\u\l\l")))
Then
'-- The above Format of PlusWorkdays works with US or UK dates!
intNumDays = intNumDays - 1
End If
Loop
End Function
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top