Skip to content

tgranqvist/fi-id-postgresql

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

Finnish personal ID in PostgreSQL

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.

Usage

  • Run the scripts in setup.sql to create the needed type and table
  • Insert test data into table
  • Run select * from people

Todo

  • Create a stored procedure that validates the check digit:
    • modulo 31 of the nine-digit ddmmyyid
    • lookup reuslt from 0123456789ABCDEFHJKLMNPRSTUVWXY
  • Extract substring date mangling into a user function
  • Calculate current age based on personal id code

Code review

Code review available here. Thanks to J_H for the input.

About

Finnish personal identity code in PostgreSQL

Topics

Resources

Stars

Watchers

Forks