SQL Timestamp Converter

Convert any date to SQL TIMESTAMP / DATETIME format. Timezone-aware.

What is a SQL Timestamp?

SQL TIMESTAMP (or DATETIME) format is YYYY-MM-DD HH:MM:SS. It's the standard literal format for date/time values in SQL databases including PostgreSQL, MySQL, SQLite, and SQL Server. The format itself carries no timezone information — the interpretation depends on your database's timezone settings.

TIMESTAMP vs TIMESTAMPTZ

In PostgreSQL, TIMESTAMP stores a date/time without timezone (what you insert is what you get back). TIMESTAMPTZ stores the instant in UTC and converts to the session's timezone on retrieval. Best practice: always use TIMESTAMPTZ and store UTC values.

Database Syntax Examples

PostgreSQL

SELECT '2024-07-15 12:00:00'::timestamp;

MySQL

SELECT CAST('2024-07-15 12:00:00' AS DATETIME);

SQLite

SELECT datetime('2024-07-15 12:00:00');