0
votes

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)?

1

1 Answers

3
votes

I think make_date() does what you want:

UPDATE test01
    SET date_column = make_date(year_col, month_cl, 1);