1

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?!

1 Answer 1

2

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.

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

2 Comments

Thanks. So I thought... but then it means the default precision for function parameters is different than the default precision for table columns. Isn't this confusing and inconsistent behavior?! I've been on this doc page. Where are these two defaults stated there?
Never mind, I figured out that the column type is actually timestamp(3). This explains it all. The parameter of the function is just timestamp which I guess means timestamp(6) (largest precision).

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.