View previous topic :: View next topic |
Author |
Message |
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Wed May 19, 2010 5:51 pm Post subject: change year portion of db2 date field |
|
|
Hello,
I have a DB2 date column with various dates and I want to change the 'year' (ccyy) portion of all the dates to '2010' ....
e.g.
2006-10-05
2008-02-10
2009-03-20
to :
2010-10-05
2010-02-10
2010-03-20
Thanks for any help..... |
|
Back to top |
|
|
NASCAR9 Intermediate
Joined: 08 Oct 2004 Posts: 274 Topics: 52 Location: California
|
Posted: Wed May 19, 2010 6:40 pm Post subject: |
|
|
tcurrier,
this works, not sure how efficient it is.
Code: |
set your_date = your_date + (SELECT YEAR('2010-12-31' - your_date )
FROM SYSIBM.SYSDUMMY1 ) YEARS |
_________________ Thanks,
NASCAR9 |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12375 Topics: 75 Location: San Jose
|
Posted: Wed May 19, 2010 7:07 pm Post subject: |
|
|
tcurrier,
You can also use this
Code: |
UPDATE TABLE
SET DATE_COL = DATE_COL + (INT(2010) - YEAR(DATE_COL)) YEARS
;
|
Kolusu |
|
Back to top |
|
|
tcurrier Intermediate
Joined: 10 Feb 2006 Posts: 188 Topics: 68
|
Posted: Wed May 19, 2010 7:57 pm Post subject: |
|
|
amazing.... thank you both ! |
|
Back to top |
|
|
|
|