Reputation: 3777
If I have DateTime date = new DateTime("1/31/2010");
and I call date.AddMonth(1)
. Will I get "2/28/2010" or will it freak out because "2/31/2010" doesn't exist? Or will I get "3/3/2010"?
(Also I'm not near a computer with Visual Studio)
Upvotes: 14
Views: 11672
Reputation: 19012
If the resulting day is not a valid day in the resulting month, the last valid day of the resulting month is used. For example, March 31st + 1 month = April 30th.
Upvotes: 53
Reputation: 16204
It will do a proper DateTime month addition and return 2/28/2010
Upvotes: 4