datediff - 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.
解决方案
DATEDIFF
确实有效,但它不会给你准确的年龄TIMESTAMPDIFF
。改用这个:
SELECT TIMESTAMPDIFF(YEAR, date_of_birth, CURDATE()) AS age from your_table;
推荐阅读
- javascript - chartjs如何自定义x轴值
- angular - 无法读取 navLinks fullcalendar Angular 中未定义的属性“发出”
- apache-spark - 将任何日期格式转换为 DD-MM-YYYY hh:mm:ss in spark
- java - 春季批处理中的多个读取器/处理器/写入器
- java - 使用双重检查锁定实现单例时我们是否需要 volatile
- typescript - 元素隐式具有“任何”类型,因为索引表达式在打字稿深度克隆中不是“数字”类型
- c++ - 如何使用运算符专门化模板?
- vmware - NSX Manager - 无法使用安装期间设置的“管理员”用户和密码访问 API
- spring - 当安全 API 不存在身份验证时,请求正文为空
- javascript - 使用立即调用的函数表达式(IIFE)