Tracking Business Days 
Author Message
 Tracking Business Days

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



Sat, 08 Feb 2003 03:00:00 GMT  
 Tracking Business Days
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




Sun, 09 Feb 2003 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Tracking Business Days

2. Working with only business days

3. Holidays and Business Days

4. Difference between dates in business days

5. Due Date Calculation - Work Days - Business Hours

6. Calculating Due Dates - Work Days - Business Hours - Helpdesk

7. Find next business Day - again

8. Getting next business day

9. Calculate business days in a year

10. Adding 5 BUSINESS DAYS to a date

11. calculating the # of BUSINESS DAYS

12. Help! Calculate Business Days

 

 
Powered by phpBB® Forum Software