如何用oracle从身份证信息中提取出生日期?

在项目开发中,有从身份证信息中提取出生日期的需求:

1.对18位身份证,因为有多个表,所以用到它们的关联,示例如下:

update pfapperosoninformation  p set p.pbirthday  = to_date(substr(p.perqualinumber,7,8),'YYYY-MM-DD')
where p.pfpeopleid = (
       select max(s.personnel_id) from app_institutions_personnel s,
       pfapprovalinformation      a,
       sys_manage_unit   u
        where    
        s.personnel_id =p.pfpeopleid and s.org_id = a.pfappid and u.mid=a.mid and u.mcode not in('41417705X','414177068','41419989X','414477167')
  )
and lengthb(p.perqualinumber)=18 and p.pbirthday is null  
 
2.对15位身份证而言,它的一个例子如下:
update pfapperosoninformation  p set p.pbirthday  = to_date(to_char('19'||substr(p.perqualinumber,7,6)),'YYYYMMDD')
where p.pfpeopleid = (
       select max(s.personnel_id) from app_institutions_personnel s,
       pfapprovalinformation      a,
       sys_manage_unit   u
        where    
        s.personnel_id =p.pfpeopleid and s.org_id = a.pfappid and u.mid=a.mid and u.mcode not in('41417705X','414177068','41419989X','414477167')
  )
and lengthb(p.perqualinumber)=15 and p.pbirthday is null  and substr(p.perqualinumber,9,2)>='01' and substr(p.perqualinumber,9,2)<='12'
posted @ 2015-04-14 13:55  yangxiaowei  阅读(4594)  评论(0编辑  收藏  举报