Automatically calculate gender based on ID number
How to calculate the gender automatically according to the ID card number, as long as you know that the 17th digit of the ID card is the gender position, the odd number is male, and the even number is female.
After knowing the rules for writing ID numbers, we can extract useful information. First of all, let's look at how to extract gender from ID number.
By judging the 17th digit of the ID card number, the odd number is male and the even number is female, we can get two implementation methods.
1. Remainder determination method
The first method is to divide the 17th digit by 2. If the remainder is 1, it is male, otherwise it is female, and then write the calculation formula:
The following code can be directly copied to the formula editor,Replace the ID number field.
{"text":"IF(EQ(MOD(VALUE(MID(身份证号,17,1)),2),1),\"男\",\"女\")","marks":[{"from":{"line":0,"ch":20,"sticky":null},"to":{"line":0,"ch":26,"sticky":null},"value":"textField_ksfyitkm","invalid":false}],"isCmData":true}
- IF
- MOD(number, divisor): returns the remainder of the division of two numbers.
- MID(A,B,C): in A string, C characters are retrieved from bit B.
- VALUE(text): converts text to numbers
- EQ(value1,value2) returns true when two values are equal. It supports numbers and dates.
Formula for calculating gender
2. IF function lists all odd numbers to determine
The second method is to list all odd items from 1 to 10. As long as the 17th digit of the ID number meets any odd number, the result is male, otherwise it is female. (This method is suitable for cases with fewer possible results. In general, we recommend that you use method 1)
The following code can be directly copied to the formula editor,Replace the ID number field.
{"text":"IF(OR(EQ(MID(身份证号,17,1),1),EQ(MID(身份证号,17,1),3),EQ(MID(身份证号,17,1),5),EQ(MID(身份证号,17,1),7),EQ(MID(身份证号,17,1),9)),\"男\",\"女\")","marks":[{"from":{"line":0,"ch":13,"sticky":null},"to":{"line":0,"ch":19,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":36,"sticky":null},"to":{"line":0,"ch":42,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":59,"sticky":null},"to":{"line":0,"ch":65,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":82,"sticky":null},"to":{"line":0,"ch":88,"sticky":null},"value":"textField_ksfyitkm","invalid":false},{"from":{"line":0,"ch":105,"sticky":null},"to":{"line":0,"ch":111,"sticky":null},"value":"textField_ksfyitkm","invalid":false}],"isCmData":true}
- IF
- MID(A,B,C): in A string, C characters are retrieved from bit B.
- OR(logical1,[logical2], …): if only one logical expression in parentheses is true, the returned result is 1, which is true.
- EQ(value1,value2) returns true when two values are equal. It supports numbers and dates.
Formula for calculating gender
3. Video demonstration
Automatic gender calculation video demonstration
4. For more information about identity, please read the document.👇:
1.Automatically calculate birthday based on ID number
2.Automatically calculate province based on ID number
3.Automatically calculate constellation based on ID number
4.Automatically calculate zodiac signs based on ID number
YIDA in order to better optimize the content and quality of YIDA user manual, it takes you 3-5 minutes to fill in the document feedback questionnaire. The document feedback questionnaire is submitted anonymously, and the questionnaire information is only used for YIDA document experience feedback collection. Thank you for your support for YIDA!
-------------------- Get the latest information YIDA, welcome to follow US--------------------