Timestamp conversion in Oracle for YYYY-MM-DD HH:MM:SS format

Teja picture Teja · Apr 25, 2012 · Viewed 275k times · Source

I'm trying to insert records with YYYY-MM-DD HH:MM:SS format into Oracle from Netezza, but I'm getting invalid date type.

How can I accomplish this one?

CREATE TABLE AM_PROGRAM_TUNING_EVENT_TMP1
(
    ST TIMESTAMP,
    ET TIMESTAMP,
    MAS_DIV_KEY INTEGER NOT NULL,
    SBSC_GUID_KEY INTEGER NOT NULL,
    STN_KEY INTEGER NOT NULL
 );


INSERT INTO  AM_PROGRAM_TUNING_EVENT_TMP1 VALUES('2012-03-28 11:10:00','2012-03-28 11:30:00',1,3636815,151);

Answer

hkutluay picture hkutluay · Apr 25, 2012

Use TO_TIMESTAMP function

TO_TIMESTAMP(date_string,'YYYY-MM-DD HH24:MI:SS')