Asked • 05/21/19

End of month calculations?

Just wondering if any know of an elegant solution for the following. If I have 30 June 2009 and I add a month I want it to go to 31 July 2009, not the 30 July 2009. This logic is based on the fact that the 30 June 2009 was the end of the month of June and when I add a month I want to go to the end of the next month. But if I have 29 June 2009 and I add a month it should go to 29 July 2009. Note I need to be able to add any number of months and I need to take into account leap years. Also I know the logic here is questionable but it is a business requirement that works with end of month contracts going to the end of the month for a month in the future. I have thought of several solution but none that are very elegant. Hence I was thinking someone might have a better way. Cheers Anthony

1 Expert Answer


Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.


Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.