At present, our country's ID card number is divided into two kinds, one is 15 digits, one is 18 bits. In the 15-bit old version of the ID card, the 7th to 12th digit is the date of birth, the last one is sex code, even number is female, odd is male. The 7th to 14th digit of the 18-digit new ID card is the date of birth, the 2nd digit is the sex code, the same even number is female and the odd number is male.
Based on this feature, we can use the function to judge. Figure 1 is the employee information form that we have entered the ID card number, we should pay attention when entering the ID number, we should make the cell format text type, or add a single quotation mark "'" to the ID card number before the transmission.
1. Extraction Date of birth
In D2, enter the formula "=if (C2) =15,text (Mid (c2,7,6)," 0 days "), TEXT (Mid (c2,7,8)," 0 days ")", drag the fill handle down to copy the formula, This completes the extraction of the date of birth (Figure 2):
2, the extraction of gender information
In E2, enter the formula "=if (MOD (C2) =15,mid (c2,15,1), MID (c2,17,1)), 2 = 1," Male "," female "), drag the fill handle down to copy the formula, thus completing the extraction of the sex information (Figure 3):
The formula is detailed: Len is the length function, mid is to extract the character function, text is the conversion format function, mod is the division function, if is the Judge function.
The date of birth formula means that if the ID number is 15 digits, the 6 characters from the 7th position are converted to the format of "0 days", otherwise (i.e. 18 ID), the 8 characters from the 7th digit are converted to the "0 days" format.
The formula for the extraction of gender information means that if the ID number is 15 digits, divide the 15th and 2 evenly, if divided, shown as female, not divisible, shown as male, ID number 18 digits, the 17th and 2 divisible, if the division, display as female, not divisible, shown as male.
In addition, if you want to convert your birth date to a true date type, simply add two minus signs to the formula in front of text, which is the offload operation, and then set the specific date type of the cell as needed.