Temporal types
Core idea
Temporal types describe calendar dates, times, timestamps and durations. Choose the type based on whether you need a date, a local clock reading or a specific instant.
Minimal example
SELECT date('2024-02-28', '+1 day');Expected SQLite rows:
2024-02-29How it works
PostgreSQL DATE stores a calendar date, TIMESTAMP WITHOUT TIME ZONE stores a date and time without zone semantics, and TIMESTAMP WITH TIME ZONE represents an instant displayed in the session time zone. INTERVAL represents durations with calendar components. SQLite has no dedicated temporal storage class; date and datetime functions here return text. Fixed ISO strings can sort chronologically when format and zone are consistent.
Practical example
SELECT datetime('2025-01-01 10:00:00', '+2 hours'), typeof(date('2025-01-01'));Expected SQLite rows:
2025-01-01 12:00:00 | textCommon mistake and practice
Do not mix local timestamps and UTC without an explicit conversion policy. Predict the date one day after 2024-02-28.