Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Calc age in years+months+days - help, please
Message
 
To
09/07/1998 10:46:17
Mark Hall
Independent Developer & Voip Specialist
Keston, Kent, United Kingdom
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00115698
Message ID:
00115859
Views:
12
Whew! Thanks to all of you. I'll let you know what the final routine looks like, if you're interested. - Gerry

>>I need to calculate a person's age in years, months, and days. Is there a function, VCX, or something like that, to do that?
>>
>>Thanks!
>>
>>- Gerry
>
>Well, I didn't have much else to do so...
>
>FUNCTION HowOld
>PARAMETERS tdDOB
>LOCAL ldNow, lnYears, lnMonths, lnDays, lnDiffDay
>
>ldNow = DATE()
>lnYears = YEAR( ldNow) - YEAR( tdDOB)
>lnMonths = MONTH( ldNow) - MONTH( tdDOB)
>
>IF lnMonths < 0
> lnYears = lnYears - 1
> lnMonths = lnMonths + 12
>ENDIF
>
>lnDays = DAY( ldNow) - DAY( tdDOB)
>IF lnDays < 0
> lnMonths = lnMonths - 1
> IF lnMonths < 0
> lnYears = lnYears - 1
> lnMonths = lnMonths + 12
> ENDIF
>
> lnDiffDay = 0
> DO WHILE GOMONTH( ldNow, -1) + lnDiffDay <> ldNow
> lnDiffDay = lnDiffDay + 1
> ENDDO
>
> lnDays = lnDiffDay
>ENDIF
>
>? lnYears, lnMonths, lnDays
** Gerry White / Hagerstown, MD, USA --
** Developing since 1986 in Foxpro, VFP, Oracle, and Java.
** http://GerrysPlace.com
Previous
Reply
Map
View

Click here to load this message in the networking platform