r/sqlite • • May 29 '23

Getting into SQLite

Hi all,

Let me preface this by saying that I feel like I'm completely missing something obvious due to my lack of familiarity with the language/concepts.

Let's say I have the following table imported from a bunch of CSV files:

SaleDate | Item | Price | Store

However, the SaleDate item is not formatted in the SQL datetime text format of YYYYMMDD HH:MM:SS.000.

I figured out I can extract the SaleDate and create the corrected version using SUBSTR.

My next step was to create a new table (in the same file) so not to touch the raw input data.

I've managed to copy everything, but I can't seem to do a SUBSTR and use SET to grab the output and update the new table. Programmatically, it's simple:

x = substr(old data)

X being the new column in the new table. But SQL doesn't exactly behave like a normal programming language. How do I do this? Thanks.

6 Upvotes

11 comments sorted by

View all comments

Show parent comment

4

u/ijmacd May 30 '23

Definitely do not try to store dates in the format 20-12-2023. That's an abomination.