Full answer
sql
SELECT date('2026-03-01') AS from_text,
date(2461100.5) AS from_julian,
date(1772323200, 'unixepoch') AS from_unix,
julianday('2026-03-01') AS as_julian,
CAST(strftime('%s', '2026-03-01') AS INTEGER) AS as_unix;| from_text | from_julian | from_unix | as_julian | as_unix |
|---|---|---|---|---|
| 2026-03-01 | 2026-03-01 | 2026-03-01 | 2461100.5 | 1772323200 |
A column declared DATE in SQLite gets NUMERIC affinity, and a value like '2026-03-01' stays TEXT because it does not look like a number. The functions date(), datetime(), julianday() and strftime() read all three forms, as long as integers are flagged with the 'unixepoch' modifier.
Choose one form per column and keep it. ISO text works with string comparison only if every value uses the same zero-padded format: '2026-03-01', never '2026-3-1'. PostgreSQL has real date, timestamp and timestamptz types that validate input, which SQLite does not do.
sql
SELECT date('2026-03-01') AS from_text,
date(2461100.5) AS from_julian,
date(1772323200, 'unixepoch') AS from_unix,
julianday('2026-03-01') AS as_julian,
CAST(strftime('%s', '2026-03-01') AS INTEGER) AS as_unix;Checked on SQLite 3.46.1, run twice with identical output.
Key points
- Common forms: ISO TEXT, REAL Julian day, INTEGER Unix time
- Date functions accept all three
- ISO text sorts correctly only with consistent zero-padding
- SQLite does not validate dates; PostgreSQL does
Common mistakes
- Mixing formats in one column
- Storing '3/1/2026' style text and sorting it
Follow-ups
- How would you enforce a valid date format with a CHECK?
- Which form would you pick for event timestamps?
Tips
- Mention that SQLite accepts invalid dates like '2026-02-30' as text