Skip to content
Advertisement

Inserting a generate_series select date statement into an array column

I have a Postgres table with a schema that looks like this –

I have a SELECT statement that will generate all the days of the year… and eventually after joining against a weekends and holiday table I want filter out all the business days to insert those dates values into the listdate date[] array column. At the moment I’m using the below to generate rows with all the days of the year:

So far I’ve tried to do the insert like so –

And this is the error it gives me –

Is there a good way to do this?

Advertisement

Answer

You need to aggregate the values into an array, either using array_agg():

Or using the array() constructor:

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement