How to get an age from a D.O.B field in MySQL?

后端 未结 13 1539
鱼传尺愫
鱼传尺愫 2020-11-29 07:01

I need to calculate the age of a \"customer\" from their date of birth.

I have tried to use the following:

DATEDIFF(year, customer.dob, \"2010

相关标签:
13条回答
  • 2020-11-29 08:00
    SELECT *, YEAR(CURDATE()) - YEAR(birthdate) AS age FROM user;
    

    I found some useful queries from below article for calculating age :- http://www.gizmola.com/blog/archives/archives/107-Calculate-a-persons-age-in-a-MySQL-query.html

    0 讨论(0)
提交回复
热议问题