Update to_char(date,'YYYY') [message #640286] |
Sun, 26 July 2015 23:03 |
|
nciteamo
Messages: 27 Registered: October 2014
|
Junior Member |
|
|
Hello Guys
i wanna update my table with this query below
update mytable
set to_char(NXTPAYDT,'YYYY') = '2018'
but it comes up an error message "ORA-00927: missing equal sign"
whats the problem? Syntax error?
may you guys help me?
Thanks in advance
|
|
|
|
Re: Update to_char(date,'YYYY') [message #640289 is a reply to message #640286] |
Sun, 26 July 2015 23:34 |
flyboy
Messages: 1903 Registered: November 2006
|
Senior Member |
|
|
Maybe syntax error too, but based on the logical nonsense. TO_CHAR( <column_name>, '2018' ) is not stored in the table, so it is impossible to directly change it. You can update the column itself, it is on you to give it proper value and it is not hard to compute it.
With a little help of simple math, something like this could (assuming that you want to keep month/day/hour/minute and second of that column):
update mytable
set NXTPAYDT = date '2018-01-01' + ( NXTPAYDT - trunc( NXTPAYDT, 'YYYY' ) );
(although I also fail to reason for this; maybe some data with year 18 are present in the table due to two digit year representation and wrong conversion steps)
|
|
|
|