Returns the DateTime resulting from adding the specified number of months to the specified DateTime.
[Visual Basic] MustOverride Public Function AddMonths( _ ByVal time As DateTime, _ ByVal months As Integer _ ) As DateTime [C#] public abstract DateTime AddMonths( DateTime time, int months ); [C++] public: virtual DateTime AddMonths( DateTime time, int months ) = 0; [JScript] public abstract function AddMonths( time : DateTime, months : int ) : DateTime;
The DateTime resulting from adding the specified number of months to the specified DateTime.
Exception Type | Condition |
---|---|
ArgumentException | is thrown if the resulting DateTime is outside the supported range. |
The result is computed by incrementing (or decrementing) the year and month parts of the specified DateTime by months months, and, if required, adjusting the day part of the resulting date downwards to the last day of the resulting month in the resulting year. The time-of-day part of the result is the same as the time-of-day part of the specified DateTime.
In more precise terms, considering the specified DateTime to be of the form y/ m/ d + t, where y is the year, m is the month, d is the day, and t is the time-of-day, the result is y1/ m1/ d1 + t, where y1 and m1 are computed by adding value months to y and m, and d1 is the largest value less than or equal to d that denotes a valid day in month m1 of year y1.[RB12]
Calendar Class | Calendar Members | System.Globalization Namespace