NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

DateTime.AddMonths

Returns the DateTime result from adding this instance to the specified number of months.

[Visual Basic]
Public Function AddMonths( _
   ByVal months As Integer _
) As DateTime
[C#]
public DateTime AddMonths(
   int months
);
[C++]
public: DateTime AddMonths(
   int months
);
[JScript]
public function AddMonths(
   months : int
) : DateTime;

Parameters

months
A number of months.

Return Value

The DateTime results from adding the specified number of months to this instance.

Exceptions

Exception Type Condition
ArgumentOutOfRangeException If the resulting DateTime is outside the supported range.

Remarks

The AddMonths method result is computed by incrementing (or decrementing) the year and month parts of this instance by value months. If required, the day part of the resulting date is adjusted 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 this instance of DateTime. In more precise terms, consider this instance 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.

The months parameter argument can be positive or negative.

See Also

DateTime Structure | DateTime Members | System Namespace | Int32 | Month