DateTime LastDayOfMonth extension method

This method returns the last day of the month of the date passed.

Public Function LastDayOfMonth(Extends Value As DateTime) As DateTime
  Var Result As New DateTime(Value.Year, Value.Month, 1) ' First day of Value month
  Result = Result.AddInterval(0, 1) ' First day of Value + 1 month
  Result = Result.SubtractInterval(0, 0, 1) ' Last day of Value month
  Return Result
End Function
1 Like