After reading https://sqlite.org/datatype3.html which states
"SQLite does not have a storage class set aside for storing dates and/or times."
but able to run this
CREATE TABLE User (ID INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, BORN_ON DATE NULL)
and then see it in "DB Browser for SQL" like this:
I start to wonder if SQLite does support Date type of it is just "faking" the support using other types. And even if so why the DB Browser see it as a Date? Any meta info stored inside the DB?
Yes, it simply stores the type name used when the column was created. The linked page calls it "declared type". In this case you get
NUMERIC
affinity (DATE
is even given as one of the examples in 3.1.1) and it behaves like any other column with this affinity:So if you insert dates looking like e.g.
"2021-01-05"
they will be stored as strings. Butyou can also insert strings which don't look like dates.
if you insert
"20210105"
it will be stored as the number20210105
.You can use
CHECK
constraints to prevent inserting non-date strings.See also https://sqlite.org/lang_datefunc.html which says what (string and number) formats date/time functions expect.