I need to calculate some dates in SQL.
I want all results where the age is between 6 weeks and 16 years old.
Not sure what the most sensible way to go about this is?
Thanks in advance
I need to calculate some dates in SQL.
I want all results where the age is between 6 weeks and 16 years old.
Not sure what the most sensible way to go about this is?
Thanks in advance
If you have a date field that represents the birth date, you need to calculate the age (with the help of NOW() function), and get only records that match your criteria. something like this:
select * from table
where (DATEDIFF(NOW(), birth_date)/7) > 16 /*16 weeks*/
and (DATEDIFF(NOW(), birth_date)/365) < 16 /*16 years*/