Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
meberg66219
Yak Posting Veteran
65 Posts |
Posted - 2011-05-10 : 14:37:12
|
| I have a table with a list of birth dates. I need to be able to select the birth dates that are either too old to be students or too young to be students. I was trying a MIN/MAX date but that only brings up one "oldest" or one "newest" birth date.Here is what I was trying:Select SSN, LastName, FirstName, SyStudentID, DOBFROMsyStudentWHEREDOB = (SELECT MAX(DOB) From Systudent)Group BYSSN, LastName, FirstName, SyStudentId, DOB |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-05-10 : 14:44:18
|
| Assuming pre-college school ages (Kindergarten through 12):SELECT SSN, LastName, FirstName, SyStudentID, DOBFROM syStudentWHERE DOB < DATEADD(year, -19, GETDATE()) OR DOB > DATEADD(year, -6, GETDATE())You can adjust the year range accordingly. |
 |
|
|
meberg66219
Yak Posting Veteran
65 Posts |
Posted - 2011-05-10 : 15:04:40
|
| Thank you so much! That worked very well. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2011-05-10 : 16:52:23
|
| >>too old to be a student?I was thinking of finally getting a degree after I retire.I probably won't hold out for an athletic scholarship though...Be One with the OptimizerTG |
 |
|
|
|
|
|
|
|