Click here to Skip to main content
13,042,630 members (84,854 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
Updated 8-Apr-13 12:20pm
Do you think that you need to do it all in SQL? How about the language of the application?

1 solution

Rate this: bad
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
Maciej Los 9-Apr-13 1:53am
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.

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.170713.1 | Last Updated 9 Apr 2013
Copyright © CodeProject, 1999-2017
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