COUNTRY_TO_ALPHA2¶
Description¶
COUNTRY_TO_ALPHA2 converts an ISO 3166-1 alpha-3 country code (3 letters) to the corresponding ISO 3166-1 alpha-2 country code (2 letters).
Returns unknown if the input is not a recognised alpha-3 code.
Syntax¶
Returns: A 2-letter alpha-2 country code string, or unknown if the input is unrecognised.
Example¶
This returns 'CH'.
This returns 'DE'.
This returns unknown — 'XXX' is not a valid ISO country code.
Example in context¶
Converts a 3-letter nationality code stored on a person to its 2-letter equivalent, e.g. for use with COUNTRY_TO_PHONE_PREFIX or PHONE_VALID.