Hi,
Using a DB2 query I need to update only the year of a date. The date is defined in DATE format. Can we do this? I could not find a way of doing this?
Can anyone help please?
Update only the year in DATE in DB2.
-
- New Member
- Posts: 4
- Joined: Wed Aug 13, 2014 12:10 pm
Re: Update only the year in DATE in DB2.
set date_column = date_column arithmetica_sign number_of_years_to_adjust_by YEARS???
Regards
Nic
Nic
-
- Global Moderator
- Posts: 490
- Joined: Sun Aug 25, 2013 7:24 pm
Re: Update only the year in DATE in DB2.
You can use YEARS. There's a whole section on Date Arithmetic in your SQL Reference,
-
- New Member
- Posts: 4
- Joined: Wed Aug 13, 2014 12:10 pm
Re: Update only the year in DATE in DB2.
Hi,
I have tried with this:
But it did not work.
I have tried with this:
Code: Select all
UPDATE table
SET YEAR(DATE) = 2017
WHERE
YEAR(DATE) = 2016;
Re: Update only the year in DATE in DB2.
That is a big waste of time. It conveys no information execept that in SOME way known ONLY TO YOU that it did not have the desired effect.But it did not work.
Is that syntax as per the manual which you were advised to consult? Did you try any other methods e.g. adding 1 year to you date field?
Regards
Nic
Nic
Create an account or sign in to join the discussion
You need to be a member in order to post a reply
Create an account
Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute