search
LoginSignup
8

More than 5 years have passed since last update.

posted at

mysqlで年齢計算

年齢計算のsql

mysql> select (YEAR(CURDATE())-YEAR(date_of_birth)) - (RIGHT(CURDATE(),5)<RIGHT(date_of_birth,5)) AS age from users;
+------+
| age |
+------+
| 36 |
+------+
1 row in set (0.00 sec)

参考

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
8