11-06-2012 12:56 PM
How Do I add one month to a date? DateTimeUtilities.ONEMONTH only adds 4 weeks. How do I add for instance one month to Jan 1, 2012 to make it Feb 1, 2012 (not Jan 29, 2012)?
Solved! Go to Solution.
11-06-2012 01:16 PM
The only way I know to do this is to put the date into a Calendar Object as you have done here:
then extract the month, add 1, and put it back, unless the result is > 11, in which case you need to reset the month to 0 and add 1 to the year.
11-07-2012 01:38 AM
You may need to consider month-days like 29, 30, and 31 separately. For example, adding 1 month to January 30, 2012- should that be February 28 (1 day less than end of month), February 29, or March 1?
You can store the true day of month separately and return either the end of month day (if the month is shorter) or the true selected day. This would allow you to add 1 month, every month, and always come up with the closest day to the desired day. For example, incrementing 1 month at a time, you would see Jan 30, Feb 29, Mar 30...