Reputation: 45
I work in a school district and we're looking to do a search to find all of the records where a student was between the ages of 3 and 5 during the time the record was created. The important fields (as far as I know) would be...
Student Name Date of Birth Notice Date (which is the date the record was created)
So, basically, if the notice date was 1/5/2013, I'd want to pull the records for any kids whose DOB falls between 1/4/2008 and 1/5/2010
Any suggestions as to how I could accomplish this?
SQL Server 2005
Upvotes: 0
Views: 104
Reputation: 13315
select [Student Name], [Date of Birth]
from <however your table is named>
where DateDiff(month, [Date of Birth], [Notice Date]) between 3 * 12 and 5 * 12 + 1
Upvotes: 1