Reputation: 4373
I have a table with integer columns 'year' and 'month' that I want to replace by a single date column. I create a new column using:
ALTER TABLE test01 ADD COLUMN date_column DATE
and can update the column values using:
UPDATE test01
SET date_column = '2001-12-28'
But I want to generate a date using the year and month columns.
How can I accomplish this in SQL (postgreSQL)?
Upvotes: 0
Views: 930
Reputation: 1269603
I think make_date()
does what you want:
UPDATE test01
SET date_column = make_date(year_col, month_cl, 1);
Upvotes: 3