This example creates a table to store a somewhat validated Finnish personal ID code and extract date of birth and gender from it. It supports the new separators from the 2023 id code reform. Test ID numbers generated using the awesome generator by telepartikkeli.
I say somewhat validated because it doesn't currently validate the checksum of the identity code. See below to do list.
- Run the scripts in setup.sql to create the needed type and table
- Insert test data into table
- Run
select * from people
- Create a stored procedure that validates the check digit:
- modulo 31 of the nine-digit
ddmmyyid - lookup reuslt from
0123456789ABCDEFHJKLMNPRSTUVWXY
- modulo 31 of the nine-digit
- Extract substring date mangling into a user function
- Calculate current age based on personal id code
Code review available here. Thanks to J_H for the input.