1

TIMESTAMP type should be fine (docs)

timestamp [ (p) ] [ without time zone ] 8 bytes both date and time (no time zone) 1 microsecond / 14 digits

Create the table like:

CREATE TABLE IF NOT EXISTS l12(
    timestamp TIMESTAMP(6) NOT NULL,

But what I get is

psycopg2.errors.DatetimeFieldOverflow: date/time field value out of range: "2019-05-23 12:16:50.954276"

When I remove the last three numbers 2019-05-23 12:16:50.954276--> 2019-05-23 12:16:50.954 the insert works.

So is it possible to save a datetime with six decimals precision into one postgresql field?

0

Thanks to Akina, I found the problem. The error has been on client-side, because I used the following in the INSERT function:

INSERT INTO l12 VALUES (TO_TIMESTAMP('2019-05-23 12:16:50.954276', 'YYYY-MM-DD HH24:MI:SS.ms'))

which fails with the mentioned ERROR: date/time field value out of range: "2019-05-23 12:16:50.954276"

Just remove that TO_TIMESTAMP function and be happy or use 'YYYY-MM-DD HH24:MI:SS.msus as the correct formating input.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.