Schoolboy error on my behalf!
To get the last day of month I was setting the date to the 1st of the following month and deducting a day.....which works fine however I was then deciding if it needed to be the year after and adding a year on rather than doing it the other way round!
Function Financial_Yearend(dDate As Date, nMonth As Integer) As Date
Dim Ye As Date
Ye = DateSerial(Year(dDate), nMonth + 1, 1)
If (Ye < dDate) Then
Financial_Yearend = DateSerial(Year(Ye) + 1, Month(Ye), Day(Ye))
Else
Financial_Yearend = Ye
End If
Financial_Yearend = Financial_Yearend - 1
End Function
Bookmarks