Interview Q&A / PostgreSQL

BeginnerQuick answer1 min readUpdated 3 Oct 2026

Why should you use timestamptz instead of timestamp in PostgreSQL?

SHORT ANSWER

timestamptz stores an absolute moment in time (converted to UTC internally) and shows it in the session time zone. timestamp stores a bare date and clock reading with no zone, so the same value means different moments for different users.

Explain it simply

Suppose an IPL match starts at 7:30 pm. If you write "7:30 pm" on a sticky note, people in London read it as London time and people in Mumbai read it as Mumbai time. That sticky note is timestamp without time zone. If you instead write "7:30 pm IST, 14:00 UTC", everyone can convert it correctly. That is timestamptz.

Despite the name, timestamptz does not store the zone. It converts the input to UTC, stores that, and converts back to the session's TimeZone setting when you read it.

Example

sql
SET TimeZone = 'Asia/Kolkata';
SELECT '2026-10-05 19:30:00+05:30'::timestamptz;
-- 2026-10-05 19:30:00+05:30

SET TimeZone = 'UTC';
SELECT '2026-10-05 19:30:00+05:30'::timestamptz;
-- 2026-10-05 14:00:00+00   (same moment, shown in UTC)

SELECT '2026-10-05 19:30:00'::timestamp;
-- 2026-10-05 19:30:00      (no zone, no conversion ever)

What to say in the interview

"I use timestamptz for any event that happened at a real moment, like created_at or a payment time. It stores UTC internally and renders in the session time zone, so servers and users in different zones agree. timestamp is only for wall-clock values with no zone, like a recurring 9 am alarm."

Common mistakes

  • Thinking timestamptz keeps the original offset; it does not.
  • Using timestamp for created_at and getting wrong results when the server time zone changes.

#postgresql#data-types#timestamps

Related questions

Practise more PostgreSQL questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open PostgreSQL quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.