Adding one year to date field in postgresql

I have a table in postgresql with field_date using the syntax "YYYY-MM-DD", I want to add a year to the field with the sentence:

table UPDATE SET date_field = DATEADD (YEAR, 1, date_field);

but postgres return:

ERROR: year column does not exist

I do not see what is wrong with the proposal

+4
source share
1 answer

Try the following:

UPDATE table SET date_field = date_field + interval '1 year'

It looks like you tried to use a SQL Server function DATEADD()that does not exist in Postgres.

+9
source

Source: https://habr.com/ru/post/1667830/


All Articles