>>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)
>
>ELSE
>
>ENDIF
This looks better than my code!
Thanks!
Tommy Tillman A+ NetWork+ MCP