Defaulting Date to End of Month
I have a requirement where a user selects or enters the number of months the End Date should be extended by and the end date should default to the End of the Month. (30th or 31st of whichever month)
For Example :- My current start date is Jan 15 2020 and my current End Date is April 10 2020 ... so the current difference in months is three. The user is now presented a choice to extend the End Date by number of months (not a calendar field but an integer field).
If the user selects five (as the number of months), the End Date should fall on the LAST Day of the month i.e. June 30 2020 (and not June 10 2020 or June 15 2020).
If the user selects six (as the number months to extend the end data by), the End Date should fall on the LAST Day of the month i.e. July 31 2020 (and not July 10 2020 or July 15 2020).
If the user selects thirteen ( as the number of months), the End Date should fall on the LAST Day of the month i.e. February 28 2021 (and not February 10 2021 or February 15 2021).
How can I accomplish this and how can I account for leap years ?