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

Add Months Test Sub
Dates Times Class

Public Sub AddMonthsTest()
    'Compare the AddMonths function to Excel's EDATE function.

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

    Const FmDate = #1/1/1991#
    Const ToDate = #1/1/1998#
    Const ForMos = 60

    Dim datStart As Date, intOff%, varResES, varResXL

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

        For intOff = -ForMos To ForMos
            varResES = AddMonths(datStart, intOff)
            varResXL = CDate(EDate(datStart, intOff))

            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.