>=MESSAGEBOX(GOMONTH(GOMONTH(DATE(),-18*12),-6)- 22)You can't go back using a different calculation and expect to always get the same result. Consider someone born on Feb. 29, 2004 (a leap year). How old is that person on Feb. 28, 2005? I think most people would say the person is one year old exactly, which is what my age calculator says, too. Now, how old is that person one day later, on Mar. 01, 2005? Again, I think most people would agree the person is one year and one day old, which is what my age calculator also says.
lox = NEWOBJECT( "AgeCalculator", "age.prg") CLEAR ldDate1 = {^2004-02-29} ldDate2 = {^2005-02-28} lox.CalculateAge( ldDate1, ldDate2) ?DTOC( ldDate1) + " to " + DTOC( ldDate2) + " = " + ; TRANSFORM( lox.nYears) + " years " + ; TRANSFORM( lox.nMonths) + " months " + ; TRANSFORM( lox.nDays) + " days" ?"Reverse calculation = " + DTOC( GOMONTH(GOMONTH(ldDate2, -lox.nYears* 12) , -lox.nMonths) - lox.NDAYS) * Result: * 02/29/2004 to 02/28/2005 = 1 years 0 months 0 days * Reverse calculation = 02/28/2004 * and ldDate1 = {^2004-02-29} ldDate2 = {^2005-03-01} lox.CalculateAge( ldDate1, ldDate2) ?DTOC( ldDate1) + " to " + DTOC( ldDate2) + " = " + ; TRANSFORM( lox.nYears) + " years " + ; TRANSFORM( lox.nMonths) + " months " + ; TRANSFORM( lox.nDays) + " days" ?"Reverse calculation = " + DTOC( GOMONTH(GOMONTH(ldDate2, -lox.nYears* 12) , -lox.nMonths) - lox.NDAYS) * Result: * 02/29/2004 to 03/01/2005 = 1 years 0 months 1 days * Reverse calculation = 02/29/2004To go backwards and always arrive at the same starting point would require a more precise calculation than GOMONTH() alone is going to give you.