Oracle date format problem
I have the following strange problem in Oracle
(Please keep in mind that I have little experience in SQL and even less in Oracle).
If I do this:
SELECT TO_CHAR(sysdate, 'YYYY-MM-DD HH24:MI') FROM dual
I get this: 2010-12-02 18:39
All fine there.
However, if I do this:
UPDATE favorite_item SET favorite_item.last_used_date = TO_DATE(sysdate, 'YYYY-MM-DD HH24:MI') WHERE favorite_item.favorite_item_id = 1
I get this in my database: 10-DEC-02
Which is the 10th of December '02 which is not correct
If I do this to confirm:
SELECT TO_CHAR(favorite_item.last_used_date, 'YYYY-MM-DD HH24:MI') AS last_used_date FROM favorite_item WHERE favorite_item.favorite_item_id = 1
I get this: 0002-12-10 00:00
Which is completely wrong.
What am I doing wrong? I feel that the date setting is not working correctly.
Thanks in advance for your help.
Don't use TO_DATE() on sysdate; sysdate is already a date.
UPDATE favorite_item SET favorite_item.last_used_date = sysdate WHERE favorite_item.favorite_item_id = 1`