Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
like image 609
Teja Avatar asked Apr 25 '12 16:04

Teja


2 Answers

Use TO_TIMESTAMP function

TO_TIMESTAMP(date_string,'YYYY-MM-DD HH24:MI:SS')
like image 157
hkutluay Avatar answered Oct 19 '22 19:10

hkutluay


INSERT INTO AM_PROGRAM_TUNING_EVENT_TMP1 
VALUES(TO_DATE('2012-03-28 11:10:00','yyyy/mm/dd hh24:mi:ss'));

http://www.sqlfiddle.com/#!4/22115/1

like image 17
aquinas Avatar answered Oct 19 '22 20:10

aquinas