Finding the Next, Previous, First, or Last Workday in the Month

Started by sukishan, Sep 04, 2009, 04:47 PM

Previous topic - Next topic

sukishan

Finding the Next, Previous, First, or Last Workday in the Month
Once you've got the routines to skip holidays, the rest is simple. If you need to find the previous or next workday, it's just a matter of skipping weekends and holidays until you find another workday. For example, the procedures in Listing 2.10 find the next or previous workday simply by calling the SkipHolidays function. In each case, the functions accepts three optional parameters:

A date, indicating the month in which to search. If this parameter is omitted, the code uses the current date.


An open recordset, containing holiday information. If this parameter is omitted, the code skips just weekends, not holidays. If it is supplied, you must supply the field name in the next parameter.


A string containing the name of a field to be searched in the open recordset. This parameter is used only if the recordset parameter isn't omitted, and it is required if you supply the recordset.
As you can see from the code in Listing 2.10, there's not much to these routines, given the workhorse procedure, SkipHolidays.
A good beginning makes a good ending