I am trying to create a table test_table that has a column year which takes an array of 'years', like so:
CREATE TABLE avg_yearly_currencies_used (
id serial PRIMARY KEY,
year date[],
CONSTRAINT first_jan_check CHECK ( date_trunc('year', year) = year )
);
The CONSTRAINT checks to see if the date is in the format such as: 2010-01-01, or 2012-01-01.
If the year column is not an array, then the above command works fine and the table is created. However, by making the date an array, and by having the CONSTRAINT, I get the following error:
ERROR: function date_trunc(unknown, date[]) does not exist
How do apply the CONSTRAINT to the array column year?