Skip to content

Instantly share code, notes, and snippets.

@abenevaut
Last active March 9, 2024 23:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abenevaut/4f48d4e849f469b65b47 to your computer and use it in GitHub Desktop.
Save abenevaut/4f48d4e849f469b65b47 to your computer and use it in GitHub Desktop.
Get age of user
  • /!\ Not enough precise /!\
'DATEDIFF(CURRENT_DATE, `user`.`user_birthday`)/365 AS user_age'
  • Working fine
'DATE_FORMAT(FROM_DAYS(DATEDIFF(NOW(), `user`.`user_birthday`)), "%Y")+0 AS age'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment