AYM: Adding or Subtracting Months To or From a Date

How to:

The AYM function adds months to or subtracts months from a date in year-month format. If necessary, you can convert a date to year-moth format using the CHGDAT or EDIT function.


Top of page

x
Syntax: How to Add or Subtract Months To or From Dates
AYM(indate, months, output_format)

where:

indate

I4, I4YM, I6 or I6YYM

Is the legacy date in integer year-month format. If the date is not valid, the function returns a 0.

months

Integer

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

output_format

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