News:

MyKidsDiary.in :: Capture your kids magical moment and create your Online Private Diary for your kids

Main Menu

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