Find the Last Workday in a Given Month

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

Previous topic - Next topic

sukishan

Find the Last Workday in a Given Month

Function dhLastWorkdayInMonth(Optional dtmDate As Date = 0, _
Optional rst As Recordset = Nothing, _
Optional strField As String = "") As Date
    ' Return the last working day in the month specified.
    Dim dtmTemp As Date
    Dim strCriteria As String
    If dtmDate = 0 Then
        ' Did the caller pass in a date? If not, use
        ' the current date.
        dtmDate = Date
    End If
    dtmTemp = DateSerial(Year(dtmDate), Month(dtmDate) + 1, 0)
    dhLastWorkdayInMonth = SkipHolidays(rst, strField, _
     dtmTemp, -1)
End FunctionTo work with these procedures, you might write a test routine like the one shown in Listing 2.13. This procedure assumes the following:

You have Jet and DAO installed on your machine.


You have a reference set to the DAO type library in your project.


You have a database named HOLIDAYS.MDB available (and you've modified the code to point to the actual location of HOLIDAYS.MDB).


HOLIDAYS.MDB includes a table named tblHolidays.


tblHolidays includes a date/time field named Date, containing one row for each holiday you want tracked.
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