Home Cooker Classes Others Rice CookerGX
Classes  >  datetime  >  AddMonths(int)
datetime class : AddMonths(int) method

Description

Gets the new datetime instance which is obtained by adding the number of months to the invoker instance.

Syntax

datetimeInstance.AddMonths(int numberOfMonths)

Arguments

ClassNameDescription
intnumberOfMonthsNumber of months

Return value

ClassDescription
datetimeNew datetime type instance which is obtained by adding the argument.

Sample code

datetime dt = new datetime(2016, 3, 4, 4, 13, 0);

datetime addMonth1 = dt.AddMonths(5);//2016/08/04 4:13:00

datetime addMonth2 = dt.AddMonths(-5);//2015/10/04 4:13:00

Notes

It's a wrapper of the System.DateTime.AddMonths(Int32).

Links for reference

Copyright © Rice All rights reserved.