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

2

15

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);
Melanism answered 25/4, 2012 at 16:33 Comment(2)
Please post the INSERT statement you're using, the DDL for your table, and an example of the data.Sural
My data is coming from a flat file... and I want to perform date transformation while inserting data...Melanism
O
18
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

Ownership answered 25/4, 2012 at 16:42 Comment(0)
R
33

Use TO_TIMESTAMP function

TO_TIMESTAMP(date_string,'YYYY-MM-DD HH24:MI:SS')
Reddy answered 25/4, 2012 at 16:37 Comment(0)
O
18
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

Ownership answered 25/4, 2012 at 16:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.