Friday, August 17, 2012

addMonths(): date manipulation in Apex

If today is March 31st, what is the date 6 months from now?  Honestly I wasn't sure what the answer should be. For Force.com Apex, it thinks that the date should be September the 30th.

Anonymous execution:

system.debug(date.valueof('2012-03-31').addmonths(6));

Result:

11:46:30.035 (35261000)|USER_DEBUG|[7]|DEBUG|2012-09-30 00:00:00


 

No comments:

Post a Comment