How to search age wise if DOB is stored in Database

#1

Hai,

i am doing Age wise search i.e age between two age but i am storing DOB in database …
How can i do age wise …?

any suggestion please…

thanks,

#2

As long as you’re storing dob as a DATE this should be as easy as calculating the age and using that.

ie

SELECT
  name,
  dob
FROM person
WHERE YEAR(CURRENT_TIMESTAMP) - YEAR(dob) BETWEEN ? AND ?
#3

Except that the difference in years isn’t your age if your birthday hasn’t occurred yet in the year. You will be that age this year, but you might not be it yet. The following returns the number of whole years between two dates -

TIMESTAMPDIFF(YEAR, dob_column, CURDATE())
2 Likes
#4

thank you,
but i am using multi select ages like in checkbox like
age=18,19,20

so how can i modify the above query
Capture11

any suggestion please…!

#5

that looks more like an IN query than BETWEEN…