The first eight digits of the IMEI number are the TAC code. Until 2004, the first six digits were the actual identifier of the device, and the next two were the final assembly code (FAC) representing where the device was manufactured. Since then, part of the FAC has been dropped.
TAC codes are issued by two authorities (CTIA for North America and GSM for everything else), identified by the first two digits. Since TAC codes are issued sequentially, you can check items three to six to identify six-digit TAC codes. For example, I use this code:
if substr(IMEI,1,2) = '01' and substr(IMEI,1,8) < '01015900' or substr(IMEI,1,2) = '35' and substr(IMEI,1,8) < '35150100' then TAC_TYPE = '6-digit'; else TAC_TYPE = '8-digit';
These ranges were determined by my personal review of TAC code tables and are not guaranteed.
See this link on Wikipedia for more details.
source share