// dates & times reference

SQL TIMESTAMP WITH TIME ZONE type

A timestamp paired with a zone or offset, stored as one instant in time and displayed in whatever zone the session or query asks for.

Catégorie
Dates & times
Returns
timestamp with time zone
In this category
108 of 121

Syntaxe

TIMESTAMPTZ '2026-08-01 14:30+02'

Prise en charge des moteurs

MoteurSupportNotes
SQL Server Different name or syntax datetimeoffset is the offset-carrying type
PostgreSQL Oui timestamptz, the type to default to
MySQL Not built in no aware type; naive DATETIME only
SQLite Not built in none; text storage conventions only
Oracle Oui TIMESTAMP WITH TIME ZONE, the original

Exemples

PostgreSQL

SELECT TIMESTAMPTZ '2026-08-01 14:30+02' AT TIME ZONE 'UTC';  -- 12:30

Oracle

SELECT CAST(TIMESTAMP '2026-08-01 14:30:00' AS TIMESTAMP WITH TIME ZONE) FROM dual;

PostgreSQL

CREATE TABLE events (starts_at timestamptz NOT NULL);

Bon à savoir

  • Neither engine stores the literal string you typed: PostgreSQL normalizes to UTC (the display offset moves with the session), Oracle keeps the stored offset in the column but converts for comparisons.
  • It is a point in time, not a schedule: '09:00 in the shop's zone' belongs in a naive timestamp plus a zone column, because timestamptz pins the instant and DST will shift future occurrences.
  • Comparisons and indexes work in UTC space, so rows inserted from Tokyo and London sort correctly: the whole reason to prefer timestamptz over naive timestamps for events.

Questions about TIMESTAMP WITH TIME ZONE

Should I always use timestamptz in PostgreSQL?

For instants, yes. Use timestamp without zone only for zone-independent wall times (schedules, opening hours), and pair those with a zone column when users span zones.

What does SQL Server offer instead?

datetimeoffset(n) carries the offset with the value; AT TIME ZONE builds and renders it. It is the closest cousin to Oracle's type.

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.