I have a table in PostgreSQL. This table has a months column and a mydate column. The months has a value of Jan the mydate has a value of 2017-01-01
I want to update that value to 2018-01-01 but I don't want to have to do it by hard coding in the 2018 date. I would like to use a date_part function but I am not sure if I am approaching this correctly.
Here is what I have so far it is not complete I am stuck on what I need to finish this query:
UPDATE tblshopstatus
Set mydate = mydate + date_part('year') -----I am stuck on this line----
WHERE months = 'Jan'
More examples:
In the months column I have all 12 months listed.
In the mydate column I have dates listed as 2017-01-01, 2017-02-01 etc... through the 12 months.
Is there a way to just increase the year to 2018 for all months.
set mydate = mydate + interval '1 year'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With