<-- Previous || Up || Next -->

Work Days Test Sub
Dates Times Class

Public Sub WorkDaysTest()
    'Compare the WorkDays function to Excel's WORKDAY function.

    'Note: You must establish a Reference to atpvbaen.xls within Excel for this to work.

    Const FmDate = #1/1/1990#
    Const ToDate = #1/1/1995#
    Const ForDays = 360

    Dim Holidays, datStart As Date, intOff%, varResES, varResXL

    Holidays = Array(#1/1/1991#, #2/15/1991#, #3/23/1991#, #4/15/1991#, #5/31/1991#, #7/4/1991#, #9/5/1991#, #11/23/1991#, #12/25/1991#, #1/1/1992#, #2/15/1992#, #3/23/1992#, #4/15/1992#, #5/31/1992#, #7/4/1992#, #9/5/1992#, #11/23/1992#, #12/25/1992#, #1/1/1993#, #2/15/1993#, #3/23/1993#, #4/15/1993#, #5/31/1993#, #7/4/1993#, #9/5/1993#, #11/23/1993#, #12/25/1993#, #1/1/1991#, #2/15/1991#, #3/23/1991#, #4/15/1991#, #5/31/1991#, #7/4/1991#, #9/5/1991#, #11/23/1991#, #12/25/1991#)

    For datStart = FmDate To ToDate
        DoEvents
        If Day(datStart) = 1 Then Debug.Print Now, datStart

        For intOff = -ForDays To ForDays
            varResES = WorkDays(datStart, intOff, Holidays)
            varResXL = CDate(WorkDay(datStart, intOff, Holidays))

            If (IsNull(varResES) And Not IsNull(varResXL)) _
            Or (Not IsNull(varResES) And IsNull(varResXL)) _
            Or (varResES <> varResXL) Then
                Debug.Print datStart, intOff, varResXL, varResES, varResES - varResXL
            End If
        Next intOff
    Next datStart

End Sub

Copyright 1996-1999 Entisoft
Entisoft Tools is a trademark of Entisoft.