SQL Datetime Format Converter

SQL datetime refers to the timestamp text formats used by relational databases: the standard `YYYY-MM-DD HH:mm:ss`, MySQL `TIMESTAMP`/`DATETIME`, PostgreSQL timestamp strings and SQL Server 121 style (`yyyy-mm-dd hh:mm:ss.mmm`). Getting the literal format right matters for INSERT/UPDATE statements and ETL.

This converter renders your date-time in the standard SQL form, MySQL TIMESTAMP(6) with microseconds, PostgreSQL convention and SQL Server style 121 with milliseconds — the four formats that cover virtually every database you will write SQL against.

Timezone:
Enter a date-time above to see the conversion results.

SQL Datetime Format Converter Quick Reference

FormatPattern / DescriptionExample 1Example 2
SQL DateTimeMySQL / PostgreSQL2026-08-13 14:30:002026-01-01 00:00:00
MySQL TIMESTAMP(6)YYYY-MM-DD HH:mm:ss.mmmmmm2026-08-13 14:30:00.0000002026-01-01 00:00:00.000000
PostgreSQL TIMESTAMPTZISO 8601 with numeric offset2026-08-13 14:30:00Z2026-01-01 00:00:00Z
SQL Server Style 121ODBC canonical with ms2026-08-13 14:30:00.0002026-01-01 00:00:00.000

* Examples are rendered in UTC for the fixed sample instants above.

When to Use SQL Datetime Format

Writing SQL literals

INSERT and WHERE clauses need correctly formatted datetime literals. Generate the exact string for your DB engine to avoid implicit-conversion surprises.

Database migration & ETL

When moving data between MySQL, PostgreSQL and SQL Server, generate each engine's canonical format to prevent truncation or timezone shifts.

Query debugging

Compare what a stored DATETIME column renders as against the string you passed in — a classic cause of "row not found" bugs.

Frequently Asked Questions

What is the standard SQL datetime format?

`YYYY-MM-DD HH:mm:ss`, e.g. 2026-08-13 14:30:00. The space between date and time (not a T) is the SQL convention used by MySQL, PostgreSQL, SQLite and most others.

What is the difference between MySQL TIMESTAMP and DATETIME?

`TIMESTAMP` stores UTC and converts on retrieval (range 1970–2038), while `DATETIME` stores wall-clock as written (range 1000–9999). Use DATETIME for historical dates; TIMESTAMP for "now"-type values.

Does SQL Server use a different format?

Yes — style 121 is `yyyy-mm-dd hh:mm:ss.mmm` (24-hour, with milliseconds). Many reporting queries fail because they pass `MM/dd/yyyy` literals that SQL Server interprets by its own dateformat setting.

Should SQL datetimes include a timezone?

SQL date/time types are usually timezone-naive. Store UTC values (`...Z` converted to naive UTC) and apply offsets in application code to avoid DST bugs.

Related Time Format Converters

All Format Guides

Need to Convert Between All Formats?

Use the main Time Format Converter for instant conversion across 100+ formats — epoch, ISO 8601, RFC 3339, SQL datetime, military time and more in one click.

Open Time Format Converter