Postgresql – How to encode a known date but unknown year

best practicesdatedatetimepostgresql

I am using a Postgres database, and have a table with a date-time field. For many records, we know the year but not the date. Sometimes we know the date but not the year. And other times we know the time but not the date.

How can I store partial date information while using the date-time data type?

Best Answer

The only thing that I can think of is to split the date into day/month and year - having one or the other as NULL as necessary. This is one of the only times I consider a split year/month/day structure, with separate fields, to be OK.