Skip to Excel formulas

NIC to DOB Excel Formula — Sri Lanka NIC Decode in Excel & Google Sheets

Need to decode hundreds of Sri Lankan NIC numbers in a spreadsheet? These copy-paste formulas work in Microsoft Excel and Google Sheets for both the old 9-digit (+ V/X) and new 12-digit NIC formats. Each formula is leap-year safe.

If you only need to decode one NIC at a time, use the online NIC to DOB tool instead — it's faster and handles edge cases automatically.

Assumption: NIC is in cell A2 as text. Old NICs end in V or X (e.g. 906731234V). New NICs are 12 digits (e.g. 199006731234). Store NICs as text (prefix cell format with apostrophe or format column as Text) to avoid Excel dropping leading zeros.

1. Detect NIC Format (Old or New)

Use this helper first — it tells you whether a cell is old (10 chars) or new (12 digits):

Detect format — Excel & Sheets
=IF(LEN(A2)=10,"Old",IF(LEN(A2)=12,"New","Invalid"))

2. Extract Date of Birth

Old NIC (9-digit + V/X) — Date of Birth

Old NIC DOB — Excel & Sheets
=DATE(
  1900 + VALUE(LEFT(A2, 2)),
  1,
  IF(VALUE(MID(A2, 3, 3)) > 500,
     VALUE(MID(A2, 3, 3)) - 500,
     VALUE(MID(A2, 3, 3)))
)

Format the result cell as Date (e.g. dd/mm/yyyy). This uses January 1 of the birth year as the base and adds the day-of-year offset.

New NIC (12-digit) — Date of Birth

New NIC DOB — Excel & Sheets
=DATE(
  VALUE(LEFT(A2, 4)),
  1,
  IF(VALUE(MID(A2, 5, 3)) > 500,
     VALUE(MID(A2, 5, 3)) - 500,
     VALUE(MID(A2, 5, 3)))
)

Universal formula (works for both old and new)

Universal DOB — Excel & Sheets
=IF(LEN(A2)=10,
  DATE(1900+VALUE(LEFT(A2,2)), 1, IF(VALUE(MID(A2,3,3))>500, VALUE(MID(A2,3,3))-500, VALUE(MID(A2,3,3)))),
  IF(LEN(A2)=12,
    DATE(VALUE(LEFT(A2,4)), 1, IF(VALUE(MID(A2,5,3))>500, VALUE(MID(A2,5,3))-500, VALUE(MID(A2,5,3)))),
    "Invalid NIC")
)
Leap year note: Excel's DATE(year, 1, day) handles leap years correctly — DATE(1984, 1, 60) returns Feb 29, 1984 because 1984 is a leap year. DATE(1983, 1, 60) returns Mar 1, 1983. No extra leap-year check is needed with the DATE function.

3. Extract Gender

If the day-of-year code is > 500, the person is female.

Old NIC — Gender

Old NIC gender
=IF(VALUE(MID(A2, 3, 3)) > 500, "Female", "Male")

New NIC — Gender

New NIC gender
=IF(VALUE(MID(A2, 5, 3)) > 500, "Female", "Male")

Universal — Gender

Universal gender
=IF(LEN(A2)=10, IF(VALUE(MID(A2,3,3))>500,"Female","Male"),
 IF(LEN(A2)=12, IF(VALUE(MID(A2,5,3))>500,"Female","Male"), "Invalid"))

4. Calculate Age from NIC

Chain the DOB formula with DATEDIF. Assumes DOB is in B2 (use the universal DOB formula above in B2):

Age in years (requires DOB in B2)
=DATEDIF(B2, TODAY(), "Y")

Or combine everything into one cell:

Age directly from NIC (old or new) — no helper column
=DATEDIF(
  IF(LEN(A2)=10,
    DATE(1900+VALUE(LEFT(A2,2)), 1, IF(VALUE(MID(A2,3,3))>500, VALUE(MID(A2,3,3))-500, VALUE(MID(A2,3,3)))),
    DATE(VALUE(LEFT(A2,4)), 1, IF(VALUE(MID(A2,5,3))>500, VALUE(MID(A2,5,3))-500, VALUE(MID(A2,5,3))))
  ),
  TODAY(), "Y"
)

5. Voter Status (Old NIC Only)

Voter status — old NIC only
=IF(LEN(A2)=10, IF(UPPER(RIGHT(A2,1))="V","Voter","Non-voter"), "N/A (new format)")

6. Convert Old NIC to New NIC

Old NIC → New NIC (assumes 1900s birth)
="19"&LEFT(A2,2)&MID(A2,3,3)&"0"&MID(A2,6,4)

This gives the 11-digit body; the 12th check digit must come from the official DRP record.

7. Full Summary Table

Output Old NIC (A2) New NIC (A2)
Date of Birth =DATE(1900+VALUE(LEFT(A2,2)),1,IF(VALUE(MID(A2,3,3))>500,VALUE(MID(A2,3,3))-500,VALUE(MID(A2,3,3)))) =DATE(VALUE(LEFT(A2,4)),1,IF(VALUE(MID(A2,5,3))>500,VALUE(MID(A2,5,3))-500,VALUE(MID(A2,5,3))))
Gender =IF(VALUE(MID(A2,3,3))>500,"Female","Male") =IF(VALUE(MID(A2,5,3))>500,"Female","Male")
Birth Year =1900+VALUE(LEFT(A2,2)) =VALUE(LEFT(A2,4))
Day-of-year =IF(VALUE(MID(A2,3,3))>500,VALUE(MID(A2,3,3))-500,VALUE(MID(A2,3,3))) =IF(VALUE(MID(A2,5,3))>500,VALUE(MID(A2,5,3))-500,VALUE(MID(A2,5,3)))
Voter status =IF(UPPER(RIGHT(A2,1))="V","Voter","Non-voter") N/A

8. Google Sheets Notes

All formulas above work identically in Google Sheets. One difference: Sheets uses commas as separators in most locales; if your Sheets uses semicolons, replace all , with ;.

Google Sheets tip: use ARRAYFORMULA to apply to an entire column at once:

Google Sheets — ARRAYFORMULA for entire column
=ARRAYFORMULA(IF(LEN(A2:A)=10,
  DATE(1900+VALUE(LEFT(A2:A,2)),1,IF(VALUE(MID(A2:A,3,3))>500,VALUE(MID(A2:A,3,3))-500,VALUE(MID(A2:A,3,3)))),
  IF(LEN(A2:A)=12,
    DATE(VALUE(LEFT(A2:A,4)),1,IF(VALUE(MID(A2:A,5,3))>500,VALUE(MID(A2:A,5,3))-500,VALUE(MID(A2:A,5,3)))),
  "")))

Only need to decode one NIC? The online tool is faster — no spreadsheet needed.

Open Free NIC to DOB Decoder →

More NIC Tools