In case anybody wants to know:
I created a couple of functions to track the business days.
Please note: This doesn't account for holidays.
<%
' This is the smaller version, and is much faster
Function BizDays( d, n )
j=WeekDay(d)-2
b=n+j
If j=-1 Then
j=-2
BizDays=DateAdd("d", (b MOD 5)-j, DateAdd("ww", b\5, d ) )
End Function
' this function is longer but a lot easier to read and understand
Function AddBizDays( byVal theDate, byVal numDays )
' we "back up" to Monday of the same week...
adjust = WeekDay(theDate) - vbMonday
' and then adjust the requested number of days by that amount
numDays = numDays + adjust
' but then adjust the adjustment, for Sundays only
If adjust = -1 Then adjust = -2
' now "back up" the given date by the same number of days...
' this backs us up to the preceding Monday (or doesn't move
' us if we are already on Monday, of course)
mondayDate = DateAdd("d", - adjust, theDate )
' then go forward by the number of weeks that are equivalent
' to the requested number of business days...that is,
' one week every 5 business days
futureDate = DateAdd("ww", numDays \ 5, mondayDate )
' finally, go forward by the number of days "left over"...
AddBizDays = DateAdd("d", numDays MOD 5, futureDate )
End Function
%>
Quote:
> I want to send an automated email 5 business days after a user submits a
> form. Is there some built-in logic to track business days in VBScript?
> Mark Petersen