Adds months to a datetime.

DateTime = SRP_DateTime("AddMonths", Datetime, Months)

Returns

A new datetime.

Parameters

ParameterDescription
DatetimeA datetime in OI internal format. (REQUIRED)
MonthsThe number of months to add. (REQUIRED)

Remarks

The "AddMonths" service calculates a new datetime by adding the given number of months to an existing datetime. You can pass whole numbers or decimal numbers. You can also pass negative values to subtract months.

Note that months are an abstract concept, so adding months is also done abstractly. If the current month is February 28, and you add 1 whole month, you will get March 28. In other words, whole months are added without altering the day of the month, unless the day would be invalid. As an example, If you add 1 whole month to January 31, you'll get February 28. Fractions of a month are calculated using the average month length, which is 30.4375. For example, if you add 1.5 months to February 28, you'll get April 12th, which is 15 days (half of 30.4375) after March 28th.

Note also that this method never alters the time of day.

Examples

// Add 10 months to the current datetime
NewDateTime = SRP_DateTime("AddMonths", DateTime(), 10)

// Add a month and a half to the current datetime
NewDateTime = SRP_DateTime("AddMonths", DateTime(), 1.5)

// Subtract 10 months from the current datetime
NewDateTime = SRP_DateTime("AddMonths", DateTime(), -10)

  • No labels