How to get Age using BirthDate column by MySQL query?

前端 未结 5 1975
滥情空心
滥情空心 2021-01-19 02:56

I have a BirthDate column in MySQL database table to store user\'s date of birth. Now I have form in html/php with two fields(1. Age From 2. Age To).

If user want t

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-19 03:18

    Another solution which checks the year and the month:

    SELECT * FROM yourTable WHERE FLOOR(DATEDIFF(curdate(), birthdate) / 365.25) BETWEEN 10 AND 20
    

提交回复
热议问题