You need to sign in to do that
Don't have an account?

Getting weird result using Date.AddMonths() method
Date endDate = date.parse('4/30/2017');
Date startDate = endDate.addMonths(-1);
Start date is now coming as 3/30/2017, where as it should be 3/31/2017. Any suggestions.
Date startDate = endDate.addMonths(-1);
Start date is now coming as 3/30/2017, where as it should be 3/31/2017. Any suggestions.
I Think you need use To get your result.
I think this may help you.
Thanks
Hemant
Hi rao,
I think addMonths is working correctly, its changing your month from 4 to 3. May be you want to change days instead of month.
Hope this will help you.
Thanks,
Manohar