Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calculating age...
Message
 
To
14/12/1999 15:34:28
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00303614
Message ID:
00303679
Views:
13
Todd,

Here's one way that is always correct and returns the years and months as a string.
FUNCTION HowOld
LPARAMETERS pdBirth, pdOn
LOCAL lnYears, lnMonths

lnMonths = 0
DO WHILE pdBirth <= pdOn
   lnMonths = lnMonths + 1
   pdBirth = GOMONTH(pdBirth,1)
ENDDO

lnMonths = lnMonths - 1
lnYears = INT(lnMonths / 12)
lnMonths = lnMonths % 12

RETURN ALLTRIM(STR(lnYears)) + " year" + IIF(lnYears<>1,"s","") + ;
           " and " + ALLTRIM(STR(lnMonths)) + " month" + ;
           IIF(lnMonths<>1,"s","")
Previous
Reply
Map
View

Click here to load this message in the networking platform