Get date the Last day of next month

How to get the last day of next month??

ex) today is 13-May-2019, want last day of June
want to get form like dd-MMM-YYYY

Hi @dlawoals,

Please find the below methods. First method will be the right approach I guess.

Method 1:



datetime.DaysInMonth(today.AddMonths(1).Year,today.AddMonths(1).Month) + today.AddMonths(1).tostring("-MMM-yyyy")

Please refer this link for your reference.


Use the code below.

Dim reference As DateTime = DateTime.Now
Dim firstDayThisMonth As New DateTime(reference.Year, reference.Month, 1)
Dim lastDayNextMonth As String = firstDayThisMonth.AddMonths(2).AddDays(-1).ToString("dd-MMM-yyyy")

Working sample: Find last day of next month, Visual Basic - rextester

One liner

Dim lastDayNextMonth As String = New DateTime(DateTime.Today.Year, DateTime.Today.Month, 1).AddMonths(2).AddDays(-1).ToString("dd-MMM-yyyy")

hi @dlawoals,

I tried your problem you asked for. The following code seem to work
New datetime(now.Date.Year, now.Date.Month,1).AddMonths(2).AddDays(-1).ToString(“dd-MMM-yyyy”, System.Globalization.CultureInfo.InvariantCulture)

hope it helps


1 Like

really helpful me thank you!!

thank you for your solution :slight_smile:

It works now thank you:)

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.