abhiramisa
abhiramisa

Reputation: 1

How can I remove milliseconds from timestamp in oracle insert query using TO_DATE?

I have a value like this '2019-05-04 12:34:20' which I obtain from another database using python code But when I run the below query in oracle,

INSERT INTO sample_table(SCHEDULED_DATE) 
VALUES (TO_DATE('2019-05-04 12:34:20','YYYY-MM-DD HH24:MI:SS'));

I am getting an output like this,

'04-05-19 12:34:20.000000000 PM'

What I want is:

'2019-05-04 12:34:20'

Upvotes: 0

Views: 702

Answers (1)

Popeye
Popeye

Reputation: 35920

What you are expecting and what you are getting is the same value.

It is just the representation. SCHEDULED_DATE is the timestamp data type and it shows milliseconds as 000..

You can use TO_CHAR to see the value in the format that you want(to_char(SCHEDULED_DATE, 'YYYY-MM-DD HH24:MI:SS')). and anyway you are adding date into timestamp so your timestamp will always have 000.. in the millisecond.

Upvotes: 1

Related Questions