Function Dates Times Class

LastDayOfPeriod

Return the last day of the period (for example, the last day of the quarter), given a date within the period and the number of periods per year.

Signature (Visual Basic / VBA)

Public Function LastDayOfPeriod( _
      ByVal vDate As Variant _
    , ByVal vPeriod As Variant _
    ) As Variant

Code Example

    LastDayOfPeriod(#1/15/99#, 1) = #12/31/99#
    LastDayOfPeriod(#1/15/99#, 2) = #6/30/99#
    LastDayOfPeriod(#1/15/99#, 4) = #3/31/99#
    LastDayOfPeriod(#1/15/99#, 6) = #2/28/99#
    LastDayOfPeriod(#1/15/99#, 12) = #1/31/99#

Parameters

Parameter Description
vDate The date used to determine the period. Function returns Null if vDate is Null or cannot be fixed up to a Date.
vPeriod The number of periods per year. Use 1 for an annual period, 2 for semi-annual, 3 for four-month period, 4 for quarterly, 6 for bi-monthly, and 12 for monthly. vPeriod must be one of these numbers or else the function will return unpredictable results. Function returns Null if vPeriod is Null or cannot be fixed up to a Date.

Notes & Version History

v2.0 Addition This function is new to this version of Entisoft Tools.