By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,493 Members | 1,233 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,493 IT Pros & Developers. It's quick & easy.

Urgent - Find age in each month of a year

P: 77
I have the list of patients in the admittance table who were in care during the years 2004, 2005 and 2006.
The admittance table has fields, CaseID, SeqNbr, Birthdate
I want to find the patients who were 18 years and 1 month old in Jan 2004, Feb 2004.....Dec 2004 (basically each month of the year).
Similarly I need to do the same for 2005 and 2006.

Please treat this as urgent....thanks for the help.
Jan 4 '08 #1
Share this Question
Share on Google+
1 Reply


puppydogbuddy
Expert 100+
P: 1,923
I have the list of patients in the admittance table who were in care during the years 2004, 2005 and 2006.
The admittance table has fields, CaseID, SeqNbr, Birthdate
I want to find the patients who were 18 years and 1 month old in Jan 2004, Feb 2004.....Dec 2004 (basically each month of the year).
Similarly I need to do the same for 2005 and 2006.

Please treat this as urgent....thanks for the help.
Try this:

The following query uses the Age() function at this link:

http://allenbrowne.com/func-08.html

Expand|Select|Wrap|Line Numbers
  1. SELECT DatePart(Year(AdmitDate)) As AdmitYear , DatePart(Month(AdmitDate)) As AdmitMonth, CaseID, SeqNbr, BirthDate, Age([BirthDate]) As BirthAge
  2. FROM AdmittanceTable
  3. WHERE Round(BirthAge,2) = 18.09
  4. GROUP BY AdmitYear,  AdmitMonth, CaseID, BirthDate, BirthAge
  5. ORDER By AdmitYear, AdmitMonth, CaseID, BirthDate; 
  6.  
Jan 5 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.