Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining age based on dob
Message
De
11/12/2001 15:11:19
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00592860
Message ID:
00592895
Vues:
15
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform