SQL Server Age calculation
Posted on 2005-05-02
Hello all I am moving an MS Access app to SQL Server
I have several append queries that calculate age.
I am having some problems with this. I keep getting that Age, Date, and Nz are not recognized functions...
INSERT INTO Person_RANK3_AGE_RX ( Person_ID )
FROM Person_TABLE INNER JOIN ((DRUGS INNER JOIN Person_PHARM_TABLE ON DRUGS.DRUG_ID = Person_PHARM_TABLE.DRUG_ID) INNER JOIN AVOID_DRUGS ON DRUGS.DRUG_DESC = AVOID_DRUGS.Medicine_Name) ON Person_TABLE.Person_ID = PATIENT_PHARM_TABLE.Person_ID
WHERE (((AVOID_DRUGS.RISK)=3) AND ((Age(Nz([Person_TABLE].[DOB],DateAdd("yyyy",1,Date()))))>64))
GROUP BY Person_PHARM_TABLE.Person_ID, DRUGS.DRUG_ID;
What this query does is it looks at a risk associated with taking a specific drug frm the AVOID_DRUGs table. and then only looks for peopel older than 64. It retrieves the DOB from the Person_table.
Should I use something similar to Datediff...?