Adds years to a date.

Date = SRP_Date("AddYears", Date, Years)

Returns

A new date.

Parameters

ParameterDescription
DateA date in OI internal format. (REQUIRED)
YearsThe number of years to add. (REQUIRED)

Remarks

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

This service does not simply add years in chunks of 365. It adds whole years without modifying the month and day if possible. January 30, 2020 falls on a leap year, but adding 1 whole year still gets you January 30, 2021. If adding a whole year would make the date invalid, the date will be adjusted. Adding 1 whole year to February 29, 2020 will get you February 28, 2021. Fractions of a year are calculated using the average year length, which is 365.25.

Examples

// Add 10 years to the current date
NewDate = SRP_Date("AddYears", Date(), 10)

// Add a year and a half to the current date
NewDate = SRP_Date("AddYears", Date(), 1.5)

// Subtract 10 years from the current date
NewDate = SRP_Date("AddYears", Date(), -10)

  • No labels