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

Quick Reply

Warning: this topic has not been posted in for at least 120 days.
Unless you're sure you want to reply, please consider starting a new topic.

Note: this post will not display until it has been approved by a moderator.

Name:
Email:
Verification:
Please leave this box empty:
Type the letters shown in the picture
Listen to the letters / Request another image

Type the letters shown in the picture:

Shortcuts: ALT+S post or ALT+P preview