Calculate age: Difference between revisions

From LemonWiki共筆
Jump to navigation Jump to search
(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...")
(No difference)

Revision as of 13:55, 10 February 2022

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