sql 根据18位身份证号计算年龄
时间: 2023-09-08 12:11:34
浏览: 127
可以使用SQL语句根据18位身份证号计算年龄,具体[步骤]([http]([http](https://geek.csdn.net/educolumn/68f28ca3131d47699e5902c5d3d74d51?spm=1055.2569.3001.10083)s://geek.csdn.net/educolumn/68f28ca3131d47699e5902c5d3d74d51?spm=1055.2569.3001.10083)s://geek.csdn.net/educolumn/41e918968ef7840279c31b7f6a0950e3?spm=1055.2569.3001.10083)如下:
1. 获取身份证号中的出生日期部分:
```sql
[select](https://geek.csdn.net/educolumn/5d806cb20badd69e4fa54cbe0d705676?spm=1055.2569.3001.10083) sub[string](https://geek.csdn.net/edu/8802d631b97a4a6af1f4d0bbf8527465?dp_token=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpZCI6NDQ0MDg2MiwiZXhwIjoxNzA3MzcxOTM4LCJpYXQiOjE3MDY3NjcxMzgsInVzZXJuYW1lIjoid2VpeGluXzY4NjQ1NjQ1In0.RrTYEnMNYPC7AQdoij4SBb0kKEgHoyvF-bZOG2eGQvc&spm=1055.2569.3001.10083)('身份证号', 7, 8) AS birthdate FROM table_name;
```