SQLite:如何计算出生日期的年龄 [英] SQLite: How to calculate age from birth date

查看:943
本文介绍了SQLite:如何计算出生日期的年龄的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

解决方案

 

code> SELECT(strftime('%Y','now') - strftime('%Y',Birth_Date)) - (strftime('%m-%d','now')< strftime %m-%d',Birth_Date));

这一个工作。

我只是移植了这个MySQL示例: http://dev.mysql.com/doc/refman/5.0/en/ date-calculate.html


What is the best way to calculate the age in years from a birth date in sqlite3?

解决方案

SELECT (strftime('%Y', 'now') - strftime('%Y', Birth_Date)) - (strftime('%m-%d', 'now') < strftime('%m-%d', Birth_Date));

This one works.
I merely ported this MySQL example: http://dev.mysql.com/doc/refman/5.0/en/date-calculations.html

这篇关于SQLite:如何计算出生日期的年龄的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆