Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error list code
Message
From
13/07/2011 04:19:37
 
 
To
12/07/2011 20:38:28
Muthu Vel
Sty Company
India
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01518027
Message ID:
01518040
Views:
52
>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}  && DateOfReference

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!
Previous
Reply
Map
View

Click here to load this message in the networking platform