logoalt Hacker News

LittleLily • today at 12:32 PM • 2 replies • view on HN

Given that most people will be doing most of the time functions in their application code anyway like you said, why would it not be better to just use `timestamp` everywhere then? They both store the same data and the only difference is that `timestamptz` adds an unnecessary conversion on read and write operations (which also changes based on the system's timezone) that you should be doing in your application anyway.


Replies

epgui • today at 12:47 PM

Your data at rest is meaningless unless it represents a point in time. You can’t generally compare timestamps or filter by > or < or do any date arithmetic, unless you have points in time or other implicit guarantees (eg.: all of the timestamps are relative to the same time zone, there is no DST, and no historical time adjustments).

When you get into the weeds, it’s almost impossible to correctly use.

➕ show 1 reply
n_e • today at 1:39 PM

Some reasons would be to document what is stored in the column and make it convenient to do interactive queries.

Otherwise we could go even further than timestamp and store the unix time in a bigint column.