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

COUNTRY_TO_ALPHA2(alpha3)

Returns: A 2-letter alpha-2 country code string, or unknown if the input is unrecognised.

Example

COUNTRY_TO_ALPHA2('CHE')

This returns 'CH'.

COUNTRY_TO_ALPHA2('DEU')

This returns 'DE'.

COUNTRY_TO_ALPHA2('XXX')

This returns unknown'XXX' is not a valid ISO country code.

Example in context

p is Person
COUNTRY_TO_ALPHA2(p.nationality_alpha3)

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.

Last updated

Was this helpful?