Skip to content

Instantly share code, notes, and snippets.

@janderudder
Last active September 30, 2022 22:14
Show Gist options
  • Save janderudder/787368a46c057e66292297b1d8a403cc to your computer and use it in GitHub Desktop.
Save janderudder/787368a46c057e66292297b1d8a403cc to your computer and use it in GitHub Desktop.
SQLite dates storing
CREATE TABLE Dates (
iso TEXT NOT NULL,
julian REAL NOT NULL,
unix INTEGER NOT NULL UNIQUE,
CHECK(iso = date(unix, 'unixepoch', 'start of day')),
CHECK(unix = strftime('%s', date(iso, 'start of day'))),
CHECK(julian = julianday(unix, 'unixepoch'))
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment