V
V
vsevolod08122014-08-06 04:24:57
PHP
vsevolod0812, 2014-08-06 04:24:57

How to select users by date of birth?

Database - mysql
Date of birth field of type DATE
Wrote a function that counts by date how many years, that is, with the date 1994-12-08 it displays 19
years
208e98a54a5f4464b13d3dfbaccd55cc.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Mikhail R, 2014-08-06
@vsevolod0812

SELECT * FROM USERS WHERE YEAR(DOB_COLUMN) = YEAR(DOB_USER)

or
But it's not scalable because it searches the entire table.

I
Ivan, 2014-08-06
@0neS

What's the problem? A link with a get parameter, such as site.ru/users/search?age=19, when selecting where user.birthday > ... and user.birthday < ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question