Gustav Brock
Gustav at cactus.dk
Fri Feb 2 08:21:07 CST 2007
Hi Virginia
We use this function:
Public Function DateSkipWeekend( _
ByVal datDate As Date, _
Optional ByVal booReverse As Boolean) _
As Date
' Purpose: Calculate first working day equal to or following/preceding datDate.
' Assumes: 5 or 6 working days per week. Weekend is (Saturday and) Sunday.
' Limitation: Does not count for public holidays.
'
' May be freely used and distributed.
' 1999-07-03, Gustav Brock, Cactus Data ApS, Copenhagen
Const cintWorkdaysOfWeek As Integer = 5
Dim bytSunday As Byte
Dim bytWeekday As Byte
bytSunday = WeekDay(vbSunday, vbMonday)
bytWeekday = WeekDay(datDate, vbMonday)
If bytWeekday > cintWorkdaysOfWeek Then
' Weekend.
If booReverse = False Then
' Get following workday.
datDate = DateAdd("d", 1 + bytSunday - bytWeekday, datDate)
Else
' Get preceding workday.
datDate = DateAdd("d", cintWorkdaysOfWeek - bytWeekday, datDate)
End If
End If
DateSkipWeekend = datDate
End Function
/gustav
>>> hollisvj at pgdp.usec.com 02-02-2007 15:06:49 >>>
Oh, yes, that would be great to have a copy.
Virginia
*******************
I also agree with Rueben. I made a similar function for my wife's database.
She required that patients records be reviewed 90 days from their admit date.
I had to make sure the the date didn't fall on a Saturday or Sunday.
Let me know if you want a copy of the function so I can dig it up for you.
David