ID card processing functions
This topic describes the functions used to process ID card numbers.
Function | Features |
DESENSITIZE_ID_CARD | Desensitizes an ID card number. |
EXTRACT_AGE | Extracts the age from an ID card number. |
EXTRACT_BIRTH_DATE | Extracts the date of birth from an ID card number. |
EXTRACT_BIRTH_DAY_OF_MONTH | Extracts the day of the month from the date of birth in an ID card number. |
EXTRACT_BIRTH_MONTH | Extracts the month from the date of birth in an ID card number. |
EXTRACT_BIRTH_YEAR | Extracts the year from the date of birth in an ID card number. |
EXTRACT_GENDER | Extracts the gender from an ID card number. |
EXTRACT_PROVINCE | Extracts the province from an ID card number. |
DESENSITIZE_ID_CARD
Description
Desensitizes a specified ID card number.
Parameters
value: Required. A string. The ID card number to be desensitized.
Return value
Returns the masked string.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.
EXTRACT_AGE
Description
Extracts the age from an ID card number.
Parameters
value: Required. A string. The ID card number.
Return value
An integer that represents the age. If the input is not a valid ID card number, this function returns NULL.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.
EXTRACT_BIRTH_DATE
Description
Extracts the date of birth from an ID card number.
Parameters
value: Required. A string. The ID card number.
Return value
The date of birth. If the input is not a valid ID card number, this function returns NULL.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.
EXTRACT_BIRTH_DAY_OF_MONTH
Description
Extracts the day of the month of birth from an ID card number.
Parameters
value: Required. A string. The ID card number.
Return value
An integer from 1 to 31 that represents the day of the month of birth. If the input is not a valid ID card number, this function returns NULL.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.
EXTRACT_BIRTH_MONTH
Description
Extracts the month of birth from an ID card number.
Parameters
value: Required. A string. The ID card number.
Return value
An integer from 1 to 12 that represents the month of birth. If the input is not a valid ID card number, this function returns NULL.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.
EXTRACT_BIRTH_YEAR
Description
Extracts the year of birth from an ID card number.
Parameters
value: Required. A string. The ID card number.
Return value
Returns the year of birth from an ID card number as an integer.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.
EXTRACT_GENDER
Description
Extracts the gender from an ID card number.
Parameters
value: Required. A string. The ID card number.
Return value
The gender extracted from the ID card number: M for male, F for female, or U for unknown. The value U is returned if the ID card number is invalid.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.
EXTRACT_PROVINCE
Description
Extracts the province name from an ID card number, such as Beijing, Zhejiang, or Hong Kong (China).
Parameters
value: Required. A string. The ID card number.
Return value
The province abbreviation is extracted from the ID card number.
Supported compute engines
MaxCompute, MySQL, RDS, Hive, AnalyticDB for PostgreSQL, PolarDB for PostgreSQL, PostgreSQL, and Spark.