Click here to Skip to main content
12,302,571 members (66,716 online)
Rate this:
 
Please Sign up or sign in to vote.
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 8-Apr-13 12:19pm
Sikaman293
Edited 8-Apr-13 12:20pm
v2
Comments
   
Do you think that you need to do it all in SQL? How about the language of the application?
—SA

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Assuming, DOB is date column, try something like this:
SELECT * FROM Table_Name WHERE datediff(year,dob,getdate()) between 50 and 75
  Permalink  
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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160530.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100