>I have student .dbf with fields 1.Regno (C) 2.Name (C) 3.DOB (D) 4.Category (C) 5. Result (C) 6.Sitting (Integer) 7.Course (C) having around 2000 records. I would like to write a "Error.prg" for four types of Error list mention below.
>
>1. List out the student whose age above 25 years as on 1st July 2011 based on DOB Field.
>
>2. List out the student whose age above 17 years as on 1st December 2011 based on DOB Field.
>
>3. List out the failed student based on Result filed. The result field having two types of value 1."Y" 2."N" if Y means "Pass" and if "N" means "Fail".
>
>4.List out Sitting filed value equal to "3".
>
>How to write?
Hi,
Try if you can work with following basic SQL-Statement:
dor = {^2011-07-01}
Select ;
name, ;
Regno,;
dob,;
year(dor)-Year(dob)-Iif(dor<Gomonth(dob,12*(Year(dor)-Year(dob))),1,0) As Age ,;
Category ,;
Result, ;
Sitting, ;
Course ;
FROM rStudents ;
into Cursor curResult1;
WHERE year(dor)-Year(dob)-Iif(dor<Gomonth(dob,12*(Year(dor)-Year(dob))),1,0) >25
Regards,
Koen
P.S. The trick to calculate age with Gomonth() is from Olaf Doschke!