AYM: Adding or Subtracting Months

How to:

The AYM function adds months to or subtracts months from a date in year-month format. You can convert a date to this format using the CHGDAT or EDIT function.


Top of page

x
Syntax: How to Add or Subtract Months to or From a Date
AYM(indate, months, output)

where:

indate

I4, I4YM, I6, or I6YYM

Is the legacy date in year-month format. If the date is not valid, the function returns the value 0 (zero).

months

Integer

Is the number of months you are adding to or subtracting from the date. To subtract months, use a negative number.

output

I4YM or I6YYM

Is the resulting legacy date.

Tip: If the input date is in integer year-month-day format (I6YMD or I8YYMD), divide the date by 100 to convert to year-month format and set the result to an integer. This drops the day portion of the date.



Example: Adding Months to a Date

AYM adds six months to HIRE_MONTH and stores the result in a column with the format I4YM.

AYM(HIRE_MONTH, 6, 'I4YM')

For 99/04, the result is 99/10.

For 98/11, the result is 99/05.


iWay Software