#### The Logic Behind The National Identity Card(NIC) Number of Sri Lanka.

Sri Lanka now has Old NIC No Format as well as a New NIC Format. Conversion of Old NIC number to New NIC number (Reference Wikipedia)Birth by year | Birth day of the year | Serial number | Check digit | Special letter | |
---|---|---|---|---|---|

Old NIC number | 64 | 104 | 275 | 7 | V |

New NIC number | 1964 | 104 | 0275 | 7 | - |

#### The following numbering system is followed in OLD Format: 641042757V

- OLD NIC has a unique 9 digit number, in the format 000000000A (where 0 is a digit and A is a letter) Digits 1 and 2: The year of birth
- Digits 3-5: The number of the day in the year on which the person's birth date falls.
- A male would be assigned the number 1-366 and a female the number 501-866. This is a way of confirming if the person's listed birth date is accurate. A male's birth date would be represented by the exact number of days, a female's birth date would be represented by the exact number of days + 500.
- Example: The first five digits of the NIC for a male born on 1 January 1997 would be 97001; however, a female born on that same date would be 97501.
- Digits 6-8 are the serial number from the Record book maintained at the Department [for the Registration of Persons].
- Digit 9 is a check digit
- The letter V stands for voter and X for a non-voter. Example: a student who applies for a NIC at 16, at which age he/she does not have the right to vote, the number on his/her card will end with an X. Cards issued in 2007 (no exact date available) no longer make this distinction – everyone is issued numbers that end with the letter V.

#### The following numbering system is followed in NEW Format: 196410402757

New NIC Format consist of 12 digit, in the format 000000000000 (where 0 is a digit)Only first 7 digits contains the date of birth logic.

First four digits represents the born year.

As you can see in the above example its "1964". That means birth year is 1964.

Then next three numeric digits represent the no of days to your birthday date from January 1.

Then next three numeric digits represent the no of days to your birthday date from January 1.

#### But when calculating the month and date, you have to consider two things.

- For all the years February month has 29 days.
- For women's this three digits will start from 500. That means for women's this three digits has an additional 500.

#### When you run the program, the output will be:

Enter Your NIC Number

Like : 000000000V or Like : 000000000000

196410402757

Your Details of given NIC Number

Year : 1964

Month : 4

Date : 13

Sex : Male

Enter Your NIC Number

Like : 000000000V or Like : 000000000000

641042757V

Your Details of given NIC Number

Year : 1964

Month : 4

Date : 13

Sex : Male

Nice Work..

ReplyDeleteThank you...

ReplyDeleteCREATE FUNCTION ENTERPRISEDB.RESOLVENIC

ReplyDelete( name_in IN varchar2 )

RETURN varchar

IS

cnumber date;

val1 number;

val2 number;

val3 number;

mo number;

da number;

days number;

yy varchar(100);

mm varchar(100);

dd varchar(100);

fulltxt varchar(100);

type montharr IS VARRAY(100) OF NUMERIC(10);

months montharr;

BEGIN

months := montharr(31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

val1 := to_number( substr(name_in, 0, 2));

val1 := val1 + 1900;

val2 := to_number( substr(name_in, 3, 3));

IF val2 > 500 THEN

val2:=val2-500;

else

val2:=val2;

end if;

days := val2;

for i in months.first..months.last

loop

if days < months(i) then

mo := i ;

da := days;

EXIT;

else

days := days - months(i);

end if;

end loop;

yy := to_char( val1 ) ;

mm := to_char( mo ) ;

dd := to_char( da ) ;

fulltxt := concat( yy||'/', mm||'/');

fulltxt := concat( fulltxt, dd);

RETURN fulltxt ;

EXCEPTION

WHEN OTHERS THEN

raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);

END;

GO

// W.I.Sudusinghe

//wi.sudusinghe@gmail.com

thanks. this is really helpful!

ReplyDeletecan you give me a flowchart for this diagrame?

ReplyDeletecan you give me flowchart and algorithm for this?

ReplyDeletethe last digit of both NICs old and new have a check digit, do know how it is generated

ReplyDeleteHello I am so delighted I located your blog, I really located you by mistake, while I was watching on google for something else, Anyways I am here now and could just like to say thank for a tremendous post and a all round entertaining website. Please do keep up the great work. fake id

ReplyDeleteHow to find my nic number

ReplyDelete## Post a Comment

Thank you for vising