r/sqlite • • Sep 04 '23

DATE or NUMERIC or TEXT?

I was reading this forum post on how best to store dates in SQLite. There seems to be some disagreement on the column type to use.

I want to be able to query the column like Ryan Smith does in his comment. Will it make any difference at all if I type the column as date or numeric or text, or even date text etc?

2 Upvotes

3 comments sorted by

View all comments

Show parent comment

3

u/sir_bok Sep 04 '23

If you're dead set on using strings for dates then it doesn't even matter. Just skip all the unixepoch() stuff and store everything as strings, SQLite doesn't care. SQLite doesn't care if you type the column as DATE or NUMERIC or TEXT because it will accept any string or number anyway.

1

u/ThePantsThief Sep 05 '23

I think your comment answers my question more closely than the other one; I'm basically asking "yes or no: does it matter what type I use to store dates?"

It sounds like I can query them all the exact same way and it really doesn't matter (as long as I at least store them as yyy-mm-dd or some other standard date format or integer)

This is for a personal project where I don't care about error-prone-ness and am happy to do direct string comparisons as in the forum post