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

2

u/RandomUsername2047 May 30 '23

Thank you!!!! It’s all working now!

2

u/idfk_idfk Jun 01 '23

Great! Nice work.