Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL-server-2005
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 13:19pm
Sikaman293
Edited 8-Apr-13 13:20pm
v2
Comments
Sergey Alexandrovich Kryukov at 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

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 at 9-Apr-13 1:53am
   
+5!
Sikaman at 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
0 Mathew Soji 270
1 BillWoodruff 260
2 Sergey Alexandrovich Kryukov 240
3 OriginalGriff 236
4 Afzaal Ahmad Zeeshan 208
0 OriginalGriff 6,168
1 Sergey Alexandrovich Kryukov 5,853
2 DamithSL 5,028
3 Manas Bhardwaj 4,539
4 Maciej Los 3,845


Advertise | Privacy | Mobile
Web04 | 2.8.1411019.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2014
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