Hi,
I have a database of names and addresses with dates of birth
I need to select records where age is not over 12 when the
record is selected. So, given a start date and an end date,
any selected record's age would not be over 12 by the
end date
Any SQL ideas?
Thanks a lot,
Brian
Hi Brian,
I assume it does depend on the version of SQL you're using, but in MS SQL you can do :
"SELECT * from <tablename> where (year(curdate())-year(date-of-birth))<=12"
while not completely exact, this should give you a clue how to continue (because this doesn't take into account the month/day)
You would probably need to write a stored function to have a correct calculation (and leave it out of your emergence code, so it gets executed on the server, probably much faster)
hope this helps..
regards,
Frank
Frank,
Thanks for your reply - this gives me a great starting point. I'll give it a go
tonight
Brian
Brian
Here is some code I have used with the Easy Database (MS ACCESS)
You just need to put your dates in as needed.
Hope it is of some help.
Allan