首页 > 解决方案 > Calculating age using date of birth stored in the database

问题描述

does anyone know if DATEDIFF function is working in Google App Maker - Calculated SQL models? I would like to calculate the age by reporting the date of birth from the database at the current date. Thank you.

标签: datediffgoogle-app-maker

解决方案


DATEDIFF确实有效,但它不会给你准确的年龄TIMESTAMPDIFF。改用这个:

SELECT TIMESTAMPDIFF(YEAR, date_of_birth, CURDATE()) AS age from your_table;

推荐阅读