The first generation of Idcard is a 15-digit number, the second generation is a 18-digit number,
New 18-digit idcard number what you mean: 1-2 provincial, autonomous, and municipality codes
3-4 prefecture-level cities, leagues, Autonomous prefecture codes
5-6 counties, county-level, District code
7-14 days of birth, such as 19670401 for April 1, 1967
15-17 digits are sequential numbers, of which 17 men are singular and women are even
18 bits are check codes, 0-9 and X, which are randomly generated by the formula.
15-digit Idcard number what you mean: 1-2 provinces, autonomous regions, municipalities, codes;
3-4 prefecture-level cities, leagues, Autonomous Prefecture code;
5-6 counties, county-level, district code;
7-12 births, such as 670401 for April 1, 1967, which is the first difference from the 18-digit number;
13-15 digits are sequential numbers, of which 15 men are singular and women are even
The second difference from the 18-digit * * *: No Last verification code
To obtain user age information from Idcard, verify the legality of Idcard.
--Determine if it is a number, return True,falsecreate or replace function dt_isnumber (P_IN VARCHAR2) return boolean as i number ; Begin i := to_number (p_in); return true; exception when others then return false; end;--to determine if it is a date, return True,falsecreate or replace function dt_isdate (P_IN VARCHAR2) return boolean as i date; Begin i := to_date (p_in, ' YYYYMMDD '); return true; exception when others then return false; end;--judge whether it is legal create or replace function dt_isidcard (P_IDCARD VARCHAR2) return boolean is idcardlen integer; Begin idcardlen := length (P_idcard); if (IDCARDLEN = 18 And dt_isnumber (SUBSTR (p_idcard, 1, idcardlen - 1)) and dt_isdate (SUBSTR (p_idcard, 7, 8)) ) OR (Idcardlen = 15 and dt_isnumber (SUBSTR (P_idcard, 1, idcardlen)) and dt_isdate (' | ' | substr (p_idcard, 7, 6) ) THEN RETURN TRUE; ELSE RETURN FALSE; END IF; end dt_isidcard;--gets the age of the information and returns Create or replace function dt_getage (P_IDCARD VARCHAR2) RETURN INTEGER ISIDCARDLEN INTEGER;IDCARDYEAR INTEGER; Begin idcardlen :=length (P_idcard); if dt_isidcard (P_ Idcard) AND IDCARDLEN = 18 THEN IDCARDYEAR := To_number (SUBSTR (p_idcard,7,4)); end if; if dt_isidCARD (P_idcard) AND IDCARDLEN = 15 THEN Idcardyear := to_number (' 19 ' | | SUBSTR (p_idcard,7,2)); end if; return to_number (TO_CHAR (SYSDATE, ' YYYY ')) -idcardyear; end dt_getage;
The above for the * * * age to get common functions to make a record, easy to use in the future or other address, gender in the further analysis of use
(PS: Why Shenfenzheng These three words to be filtered out as sensitive information)
This article from the "Down-to-earth, look at the Stars" blog, please be sure to keep this source http://xubcing.blog.51cto.com/3502962/1596182
Oracle functions get Age in Idcard