Get difference in years between two dates in MySQL as an integer

后端 未结 9 2064
死守一世寂寞
死守一世寂寞 2020-11-30 10:59

I am trying to calculate how old is a person in a database.
Let\'s suppose to have this simple table:

student(id, birth_date);

Where

9条回答
  •  旧时难觅i
    2020-11-30 11:44

    select id, floor(datediff(curdate(),birth_date) / 365)
    from student
    

    What about flooring the result to be an integer?

提交回复
热议问题