I have a postgres DB with a "timestamp" column of the type "timestamp without time zone".
If the following timestamp ("2013-01-01 12:13:14.000") is inserted into the DB, it is displayed (using PgAdmin or psql from command line) as "2013-01-01 12:13:14".
Is there an optional switch or setting that can be set in the DB somewhere that will allow the DB to display the full extent of the precision it can handle? For example I would like for it to display "2013-01-01 12:13:14.000" even if the milliseconds are indeed zero.
Of course, this is merely for quick viewing on the fly.
Your help in this regard is highly appreciated. :)
Don't use the timestamp type to store timestamps, use timestamptz (also known as timestamp with time zone) instead.
In a literal that has been determined to be timestamp without time zone , PostgreSQL will silently ignore any time zone indication. That is, the resulting value is derived from the date/time fields in the input value, and is not adjusted for time zone.
Doesn't look like there is any such option.
What you can do instead is use to_char
:
SELECT to_char(TIMESTAMP '2013-01-01 12:13:14.001', 'YYYY-MM-DD HH:MI:SS:MS');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With