Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining age based on dob
Message
From
11/12/2001 16:34:09
 
 
To
11/12/2001 15:11:19
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00592860
Message ID:
00592952
Views:
14
Jim & Joy,

(that has a ring to it *grin*)

Calculating years using this method (dividing by 365.25) does not work properly in all cases. Specifically, it falls apart on the person's birthday, when the number of years is not divisible evenly by 4.

>
>You can mess with this:
>
>
?dob({^1987/05/02})
>
>PROCEDURE dob
>    LPARAMETERS tDOB
>
>    nYear = INT( ( DATE( ) - tDOB) / 365.25 )
>    nMonth = ( MOD( ( DATE( ) - tDOB), 365.25 ) ) / 30
>
>    cAge = ALLTRIM( STR( nYear ) ) + " years and " ;
>        + ALLTRIM( STR( nMonth, 4 ,1 ) ) + " months"
>
>    RETURN cAge
>
Steve Gibson
Previous
Reply
Map
View

Click here to load this message in the networking platform