Calculate age

From LemonWiki共筆
Revision as of 13:55, 10 February 2022 by Unknown user (talk) (Created page with "Calculate age in Excel or MySQL == In Excel == If the column value is well-formatted * {{kbd | key=<nowiki>=(TODAY()- BIRTH_DAY)/365</nowiki>}}<ref>[https://www.ablebits.com...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Calculate age in Excel or MySQL

In Excel

If the column value is well-formatted

  • =(TODAY()- BIRTH_DAY)/365[1]
  • =ROUNDDOWN(YEARFRAC(BIRTH_DAY, TODAY(), 1), 0)

In MySQL

SELECT `birth_date`, TIMESTAMPDIFF (YEAR, `birth_date`, CURDATE()) AS age
FROM `my_table` 
WHERE `birth_date` IS NOT NULL

[2]

References