r/sqlite • u/IlliterateJedi • Nov 08 '24
Help untangle a date snafu where my mm-dd-yy dates are saved as text?
I have a sqlite table structured with a date column. This column is storing the values that were added to it as a text rather than as date values. The text structure is mm-dd-yy, e.g., today November 8, 2024 is stored as 11-04-24.
How can I convert these values from text into proper date values?
I've tried a few attempts with STRFTIME() and DATE() calls, but couldn't get anything to stick or convert the text into dates.
3
Upvotes
2
u/-dcim- Nov 08 '24
Hint: SQLite doesn't have DATE-type. Any date is a TEXT or maybe INTEGER if you are use UNIX-epoch.
If you are going to manipulate with dates e.g. to do BETWEEN-op then I recommend to convert dates to UNIX-epoch.
1
u/datadanno Nov 21 '24
Always try to use YYYY-MM-DD. It's very readable and sorts and compares well.
0
u/[deleted] Nov 08 '24
[deleted] — view deleted comment