Here's more reusable solution - and can do a lot more than you need - it's global function - or for you nvo lovers you can put it one of those :
>
/*
WHAT IT DOES
pass a date & the days, months, years that you would like to add to it
and it returns the new date
USAGE
you can send any number in ai_days ai_months ai_years including negative numbers
and months greater than 12 (e.g. ai_months = -18 means 18 months in the past)
ARGUMENTS
date adt_change - pass in & return with changed date
intger ai_days
integer ai_months
integer ai_years
return integer
*/
try
integer li_add_years
integer li_new_day
integer li_new_month
integer li_new_year
integer li_total_months
add the days
if ai_days <> 0 then
adt_change = relativedate(adt_change,ai_days)
if isnull(adt_change) then throw STOP
end if
save changed day & month & year
li_new_day = day(adt_change)
if isnull(li_new_day) then throw STOP
li_new_month = month(adt_change)
if isnull(li_new_month) then throw STOP
li_new_year = year(adt_change)
if isnull(li_new_year) then throw STOP
change the month
if ai_months <> 0 then
li_total_months = li_new_month + ai_months
li_new_month = mod(li_total_months,12)
if isnull(li_new_month) then throw STOP
li_add_years = int(li_total_months/12)
if isnull(li_add_years) then throw STOP
if li_total_months <=0 then li_new_month += 12
end if
change the year
li_new_year += li_add_years + ai_years
reset date
adt_change = date(li_new_year,li_new_month,li_new_day)
if adt_change = 1900-01-01 or isnull(adt_change) then
throw STOP
return SUCCESS
catch (runtimeerror lrteo_error)
return logerror(lrteo_error)
end try