Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determining age based on dob
Message
De
11/12/2001 16:34:09
 
 
À
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:
00592952
Vues:
13
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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform