0

I have a table in Oracle with timestamp data in "JAN-16-15 05.10.14.034000000 PM". When I created the table in postgresql with "col_name timestamp" it is showing data as "2015-01-16 17:10:14.034".

Any suggestions on how can set the column to get the data format as in postgre same to what I have in Oracle?

1
  • This is my timstamp in the database. Do I have to set something on database level in postgresql ----------db=> select current_timestamp; current_timestamp ------------------------------- 2019-03-22 13:40:55.482237+00 Commented Mar 22, 2019 at 13:41

1 Answer 1

1

Timestamps (or dates or numbers) do not have any "format2. Neither in Postgres nor in Oracle or in any other relational database).

Any "format" you see, is applied by your SQL client displaying those values.

You need to configure your SQL client to use a different format for timestamp, or use the to_char() function to format the value as you want.

In particular, to get the format you desire, use

SELECT to_char(current_timestamp, 'MON-MM-YY HH.MI.SS.US000 AM');

The output format can be changed in psql by changing the DateStyle parameter, but I would strongly recommend to not change it away from the default ISO format as that also affects the input that is parsed.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.