Skip to content

Instantly share code, notes, and snippets.

@cognitom
Created October 20, 2011 08:52
Show Gist options
  • Save cognitom/1300717 to your computer and use it in GitHub Desktop.
Save cognitom/1300717 to your computer and use it in GitHub Desktop.
誕生日から年齢を取得
SELECT
YEAR(NOW()) - YEAR(birthday) - IF(DATE_FORMAT(birthday, '%m%d') > DATE_FORMAT(NOW(), '%m%d'), 1, 0)
AS "age"
FROM a_table
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment