Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determining age based on dob
Message
From
11/12/2001 15:11:19
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00592860
Message ID:
00592895
Views:
14
>How can I create an expression in expression builder to get a age of person based on their date of birth. For example:
>
>Dob          Age
>10/25/44     53.4
>
>
>I tried the expression (date()-person.dob) but it gave me an error as Ambigious date/datetime contstant. Is it even possible to find number of years and months in expression
>
>
>Thanks
>Nick Patel

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
Jim Philippi

quando omni flunkus moritati
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform