PostgreSQL Subtract exactly a year from a date field PSQL -
i tried sql subtract year syntax in psql didn't work. in case dates imported 2 digit years have birthdays off 1900 years.
update patients set birthday = dateadd(year, 100, getdate(birthday)
throws:
error: syntax error @ or near "table" line 1: update table set datefield = date_add(datefield, interval 1 ...
this works in postgresql using interval , passing in string of increment values , type (seconds, minutes, hours, days, months, years) etc.
update patients set birthday = birthday + interval '1900 years';
found idea here https://www.postgresql.org/docs/9.1/static/functions-datetime.html
Comments
Post a Comment