Fork me on GitHub
#sql
<
2019-06-06
>
jumar08:06:12

Btw. on the general advice to "always use UTC" - it's not always that easy: https://codeblog.jonskeet.uk/2019/03/27/storing-utc-is-not-a-silver-bullet/

valtteri08:06:25

Why I recommend always using TIMESTAMPTZ over TIMESTAMP is that I think this is dangerous:

INSERT INTO dummy.ts_test(ts, ts_tz)
VALUES ('2019-06-06T11:48:51.133+08', '2019-06-06T11:48:51.133+08');

SELECT * FROM dummy.ts_test;
           ts            |           ts_tz
-------------------------+----------------------------
 2019-06-06 11:48:51.133 | 2019-06-06 03:48:51.133+00
(1 row)
Postgres happily accepts value 2019-06-06T11:48:51.133+08 for TIMESTAMP field and just ignores the +08 which could lead to interesting results.

valtteri09:06:54

And yes, probably just “always use UTC” is not enough for all edge-cases but it’s the most sane approach I’ve encountered so far. 🙂

👍 4