SQL Timestamp
DATETIME / TIMESTAMP columns. No timezone info — ambiguous without context.
Convert any date to SQL TIMESTAMP / DATETIME format. Timezone-aware.
DATETIME / TIMESTAMP columns. No timezone info — ambiguous without context.
Same format but always in UTC. Unambiguous when your DB stores UTC.
DATE column format: YYYY-MM-DD
Timezone-aware alternative. Use when your DB supports TIMESTAMPTZ.
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.
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.
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');