Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Minimum Age to Buy
Message
 
À
08/03/2007 16:28:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01202103
Message ID:
01202119
Vues:
12
>>Hi Gang!
>>
>>Question....
>>
>>I am coding up a Pharmacy checkout app.... to handle drugs.
>>
>>The code has to be able to determine if a person is too young to purchase the drug.
>>
>>The minimum age will be called sigcap_config.MINAGE
>>
>>Given Today.... DATE() and their birthdate pse_trans.birthdate how would you code it?
>>
>>I tried this.....
>>
>>IF NOT (YEAR(DATE()) - YEAR(Thisform.p_pse_birthdate) >= sigcap_config.minage)
>>	MESSAGEBOX('Purchaser needs to be at least ' + ALLTRIM(STR(sigcap_config.minage)) + ' years old to purchase.',0+16+0,"ID Not Accepted",10000)
>>	Thisform.p_pseIDapproved = .F.
>>	RETURN
>>ENDIF
>>
>>
>>But I don't feel comfortable about using the YEAR function this way... something about fractional parts of the year not being involved.
>>
>>Any better ways?
>>
>>Thanks!
>
>Given that MinAge is in whole years how about something like
>IF GOMONTH(DATE(),MinAge*-12) >= Thisform.p_pse_birthdate)
>    && OK
>ELSE
>    && Error code
>ENDIF
This looks better than my code!

Thanks!
Tommy Tillman A+ NetWork+ MCP
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform