Last active
September 30, 2022 22:14
-
-
Save janderudder/787368a46c057e66292297b1d8a403cc to your computer and use it in GitHub Desktop.
SQLite dates storing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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