Click here to Skip to main content
16,008,010 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi anyone - I have a database in my DataWarehouse called "dbo.Full Roster". After running a query to open this I get a table with headers, "source", "payer", "patient", "dob", "gender", "addr", etc. Under the dob column are date of births formatted as such: Mar 9 1963 12:00AM, Sep 24 1936 12:00AM, Jan 21 1961 12:00AM, Aug 29 1952 12:00AM, and so forth. I would appreciate any help with a quick code or query that can capture all patients within the age group 50 to 75 years of age. Thank you kindly. Sikaman
Posted
Updated 8-Apr-13 12:20pm
v2
Comments
Sergey Alexandrovich Kryukov 8-Apr-13 18:42pm    
Do you think that you need to do it all in SQL? How about the language of the application?
—SA

1 solution

Assuming, DOB is date column, try something like this:
SQL
SELECT * FROM Table_Name WHERE datediff(year,dob,getdate()) between 50 and 75
 
Share this answer
 
Comments
Maciej Los 9-Apr-13 1:53am    
+5!
Sikaman 9-Apr-13 8:50am    
From Sikaman to Om Prakash Pant. Your solution much appreciated! It worked! Is there anyway of personally getting in touch with you...possible negotiated comp. for much anticipated sql queries. cbonsu2@verizon.net

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900