peter.petrov
peter.petrov

Reputation: 39457

Timestamp issue - inconsistent behavior - PostgreSQL

In Postgres I have a function which accepts a timestamp parameter. I have a table which also has a timestamp column.

In the function code I do this. I take the input parameter and insert it into the table's timestamp column.

But now it turns out that my timestamp parameter contains values like 2019-02-13 09:47:22:788125 while in the table I get just 2019-02-13 09:47:22:788000.

So it seems that I lose precision (I lose these .000125) by just inserting into the table, even though both type of parameter and type of column are defined as simply timestamp. How come?!

Upvotes: 1

Views: 247

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269763

timestamp values take a precision argument (see the documentation).

So, although the values are both timestamps, they are not both necessarily of the same precision.

Upvotes: 2

Related Questions