For Answers, see/post comments

How to get the Last day of month

Dim currentDate As DateTime = DateTime.Now.Date

Dim sDate As DateTime = currentDate.Subtract(New TimeSpan(currentDate.Day - 1, 0, 0, 0, 0)).ToShortDateString()

Dim EndDate As String=sDate.Add(New TimeSpan(DateTime.Now.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)-1, 0, 0, 0, 0)).ToShortDateString()

Public Function ComputeLastDayOfMonth(ByVal TheDate As Variant) As Integer

LastDayOfMonth = DatePart("d", DateAdd("d", -1, DateAdd("m", 1, DateAdd("d", - DatePart("d", TheDate) + 1, TheDate))))

End Function

intX = ComputeLastDayOfMonth("2/2000")

No comments: