【自作関数】営業年度の末日を取得

Posted by: okap1104 - Posted on:

引数で渡した日付から営業年度の末日を取得する。
※第2引数に「1~12」を渡すことで、営業年度の開始月を変更できる(デフォルトは4月)

Public Function cmnfunc_getBizYearEnd(ByVal datDate As Date, Optional ByVal lngMonth As Long = 4) As Date
    If Month(datDate) < lngMonth Then
        cmn_getBizYearEnd = DateSerial(Year(datDate), lngMonth, 0)
    Else
        cmn_getBizYearEnd = DateSerial(Year(datDate) + 1, lngMonth, 0)
    End If
End Function