// dialect comparison

Parse text into a date in SQL Server, PostgreSQL, MySQL, SQLite and Oracle

ISO format is the universal language; every other layout needs engine-specific parsing.

Filed under Types & casting

The verdict

ISO text is the only portable input. For anything else the mask syntaxes differ enough that parsing code does not survive an engine switch, so fix the format at the source when you can.

Where they differ

The rule of thumb: send ISO 8601 ('2026-11-20') and all five engines parse it without help. For text in other layouts, each engine wants its own parsing function and mask syntax.

How each engine writes it

SQL Server

SELECT CAST('2026-11-20' AS DATE), TRY_CONVERT(DATE, '20/11/2026', 103);

Casting ISO text to DATE is safe under any language setting, but to DATETIME it is not: under SET LANGUAGE british, '2026-11-05' becomes May 11. CONVERT's third argument is a style code; 103 is dd/mm/yyyy.

PostgreSQL

SELECT DATE '2026-11-20', TO_DATE('20/11/2026', 'DD/MM/YYYY');

ISO input parses regardless of session settings; TO_DATE handles other masks. Ambiguous input like 03/04/2026 follows the DateStyle setting.

MySQL

SELECT STR_TO_DATE('20/11/2026', '%d/%m/%Y'), CAST('2026-11-20' AS DATE);

STR_TO_DATE takes %-masks (%d day, %m month, %Y 4-digit year). Invalid input returns NULL with a warning.

SQLite

SELECT DATE('2026-11-20');

The date functions accept only a handful of ISO-style formats; there is no arbitrary-mask parser. Normalize in SQL or the app first.

Oracle

SELECT TO_DATE('20/11/2026', 'DD/MM/YYYY') FROM dual;

Always pass the mask: TO_DATE('20/11/2026') without one depends on the session's NLS_DATE_FORMAT and breaks on other machines.

Questions that come up

Why did my date parse on one machine and fail on another?

Session language settings (SQL Server's LANGUAGE, PostgreSQL's DateStyle, Oracle's NLS_DATE_FORMAT) decide how ambiguous text is read. Passing an explicit mask or ISO text removes the dependency.

How do I parse a timestamp with time?

Same functions: TO_DATE becomes TO_TIMESTAMP in Oracle, STR_TO_DATE takes %H:%i:%s masks in MySQL, and CONVERT(DATETIME, ..., 120) reads ISO text in SQL Server.

Is '03/04/2026' March 4 or April 3?

Engine- and session-dependent, which is exactly why you never parse ambiguous layouts implicitly. Demand a mask or ISO text.

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.