开发者

Error Coming back from DateTime

int monthCount = GetMonthCount(comp.PaymentFrequency);
int day = comp.MaturityDate.GetValueOrDefault(DateTime.Today).Day;
DateTime countFrom = comp.EffectiveDate.GetValueOrDefault(DateTime.Today);

return new DateTime(countFrom.Year, countFrom.Mont开发者_如何学JAVAh, day).AddMonths(monthCount);

Year, Month, and day parameters describe an unrepresentable datetime? Why?


If MaturityDate is 1/31/2011 and EffectiveDate is 2/28/2011, your code will try to create a non-existent date.


Perhaps this approach will help:

If you want to get the date that is one month from a specified date, use AddMonths:

DateTime startDate = DateTime.Parse("1/31/2011");
DateTime endDate = startDate.AddMonths(1);

Here, endDate = 2/28/2011.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜