// dialect comparison

Convert a Unix timestamp to a date in SQL Server, PostgreSQL, MySQL, SQLite and Oracle

The inverse of extract-epoch, and just as engine-specific.

Filed under Types & casting

The verdict

PostgreSQL and MySQL name the operation; SQL Server and Oracle add seconds or fractions of days to 1970; SQLite needs the unixepoch keyword or it silently misreads the number as a Julian day.

Where they differ

Turning 1763600000 back into a timestamp (2025-11-20 00:53:20 UTC): two engines name it, three do arithmetic or a modifier. As with the forward direction, the time zone semantics decide whether you get the instant you meant.

How each engine writes it

SQL Server

SELECT DATEADD(SECOND, 1763600000, '1970-01-01');

Adds seconds to 1970 and returns the UTC wall time as datetime. DATEADD's number argument is an int, so convert millisecond values to seconds first. For a zone, chain AT TIME ZONE 'UTC' AT TIME ZONE 'Pacific Standard Time'.

PostgreSQL

SELECT TO_TIMESTAMP(1763600000);

Returns timestamptz, so it renders in the session zone; cast to timestamp for UTC wall time.

MySQL

SELECT FROM_UNIXTIME(1763600000);

Interprets in the session time zone; FROM_UNIXTIME(1763600000, '%Y-%m-%d') formats in one step.

SQLite

SELECT DATETIME(1763600000, 'unixepoch');

The unixepoch modifier is mandatory: without it the number is read as a Julian day and the result is NULL. Returns UTC text.

Oracle

SELECT DATE '1970-01-01' + 1763600000 / 86400 FROM dual;

Seconds / 86400 is a fractional day count, and DATE keeps whole seconds, so this returns 2025-11-20 00:53:20 as UTC wall time.

Questions that come up

Why does SQLite return NULL for my timestamp?

Without a modifier, DATETIME(1763600000) reads the number as a Julian day number, far outside the supported years 0000 to 9999, so the result is NULL. Pass 'unixepoch' (or 'auto' on recent versions).

How do I handle millisecond timestamps?

Divide by 1000 first for the engines without fractional support, or pass seconds as a real: TO_TIMESTAMP(1763600000.5) in PostgreSQL keeps sub-second precision.

Which time zone does the result land in?

PostgreSQL renders timestamptz in the session zone and MySQL follows the session zone; SQL Server and Oracle arithmetic gives you the raw UTC instant; SQLite gives UTC text you convert with modifiers.

Keep reading

// write it once, run it anywhere

Switch engines without relearning SQL

SQLly is a native SQL workbench for macOS, Windows and Linux. Its formatter and plan viewer work in all five dialects.