您的位置:首页 > 数据库 > MySQL

mysql中通过身份证计算年纪

2018-01-23 14:22 232 查看
SELECT * FROM (
SELECT
borrower_idcard idcard,
substring(borrower_idcard,7,8) birth,
year(now())- year(substring(borrower_idcard,7,8)) age,
borrower_name NAME
FROM
jr_finance_business_info
WHERE
loan_time >= 1483200000
AND loan_time < 1514736000
and `status`>=0
and xu_business_id = 0
and borrower_idcard  != '' ) t1
where t1.age>=18 and t1.age<=24;
substring()函数用来截取出生年月
year(now())- year(substring(borrower_idcard,7,8)) age, 用来计算年纪

                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: