Temporal literals
Overview
A temporal literal represents a calendar date, time of day or timestamp. Separate a local clock reading from an instant on the global timeline. A date such as 2024-02-29 has no time of day.
First example
SQLite 3.46.1.
SELECT date('2024-02-29'), time('12:34:56'), datetime('2025-01-01 09:30:00');Observed rows (JSON notation):
[ [ "2024-02-29", "12:34:56", "2025-01-01 09:30:00" ]]How it works
PostgreSQL accepts typed literals such as DATE followed by a quoted ISO date, TIME followed by a quoted clock value, and TIMESTAMP followed by a quoted date and time. SQLite uses text, Julian day numbers or Unix seconds rather than dedicated temporal storage types. Its date(), time() and datetime() functions produce formatted text. Use explicit unixepoch for Unix seconds; do not assume a bare numeric argument is Unix time.
Practical example
SQLite 3.46.1.
SELECT datetime(0, 'unixepoch'), unixepoch('1970-01-02 00:00:00');Observed rows (JSON notation):
[ [ "1970-01-01 00:00:00", 86400 ]]Practice and common mistakes
Avoid ambiguous dates such as 03/04/2025. Practice: convert Unix second 86400 to a date using the second example. Predict 1970-01-02. Fixed literals are used here rather than the current clock for reproducibility.
PostgreSQL 17 — not executed
SELECT DATE '2024-02-29', TIME '12:34:56', TIMESTAMP '2025-01-01 09:30:00';Expected result: Date 2024-02-29, time 12:34:56, timestamp 2025-01-01 09:30:00.