J
Jackson via AccessMonster.com
Hi,
I'm using the following code to add business days to a set date in my form:
Function AddWeekdays(ByVal dtStart As Date, ByVal iDaysToAdd As Integer) As
Date
Dim dtTemp As Date
dtTemp = DateAdd("ww", iDaysToAdd \ 5, dtStart) ' add whole weeks first
dtTemp = DateAdd("d", iDaysToAdd Mod 5, dtTemp) 'add on part-week days
If Weekday(dtTemp, vbMonday) > 5 Then dtTemp = DateAdd("d", 2, dtTemp)
AddWeekdays = dtTemp
End Function
It works for every day of the week except Friday but I can't work out why.
Does anyone know the reason or have better code to accomplish this?
Thanks!
I'm using the following code to add business days to a set date in my form:
Function AddWeekdays(ByVal dtStart As Date, ByVal iDaysToAdd As Integer) As
Date
Dim dtTemp As Date
dtTemp = DateAdd("ww", iDaysToAdd \ 5, dtStart) ' add whole weeks first
dtTemp = DateAdd("d", iDaysToAdd Mod 5, dtTemp) 'add on part-week days
If Weekday(dtTemp, vbMonday) > 5 Then dtTemp = DateAdd("d", 2, dtTemp)
AddWeekdays = dtTemp
End Function
It works for every day of the week except Friday but I can't work out why.
Does anyone know the reason or have better code to accomplish this?
Thanks!