MySQL:

1、select (date_format(from_days((to_days(now()) - to_days(birthday))),'%Y') + 0) AS age from table.

2、select timestampdiff(YEAR,birthday,curdate()) AS age from table

 

SQLite:

1、SELECT (strftime('%Y', 'now') - strftime('%Y', birthday)) - (strftime('%m-%d', 'now') < strftime('%m-%d', birthday)) from customer;

2、select cast(strftime('%Y.%m%d', 'now') - strftime('%Y.%m%d', birthday) as int) from customer;

相关文章:

  • 2021-07-22
  • 2022-12-23
  • 2021-11-30
  • 2022-03-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-22
猜你喜欢
  • 2021-11-16
  • 2021-11-30
  • 2021-11-17
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案