mysql - How to find list of people whose age is between a range? -


i have situation have date-of-birth stored in database eg. 1990/03/15. want find out info. of records age between 20 & 30. how should write query?

i have tried this: age of candidates using query:

select timestampdiff(year,dob,curdate()) age `profile` 

how use list of candidates between age 20 & 30?

the now() gives current date. now, date 20 , 30 years older, can following:

date_sub(now(), interval 20 year) ,  date_sub(date, interval 30 year) 

now remaining query simple. is,

select * person  dateofbirth between date_sub(now(), interval 20 year)                    , date_sub(date, interval 30 year) 

Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -