Skip to content

Columns defined as TIMESTAMP DEFAULT 0 scan to the year -4713 #290

Discussion options

You must be logged in to vote

This is explained in the driver documentation.

The default format used by the driver is auto, which is detailed in the SQLite documentation and the TimeFormat.Decode documentation; it's safe to use from at least 1980 through at least 2260, otherwise there is ambiguity.

The value 0 (zero) is one such case. Note that if you fire up the sqlite3 CLI, or open the SQLite3 Fiddle, and run the query SELECT datetime(0); the result is precisely -4713-11-24 12:00:00.

So this is not a bug, simply an incompatibility with mattn, and not SQLite; between mattn and SQLite, I'll follow SQLite.

That said, if you'd prefer to use Unix timestamps for everything, you can set _timefmt to unixepoch or unixepoch_frac

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@john-floren-gravwell
Comment options

@ncruces
Comment options

Answer selected by ncruces
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #289 on July 09, 2025 22:08.