UPDATE table
SET [Date] = SUBSTR([Date], -4) || '-' || (CAST([Date] AS INT)) || '-' ||
(CAST(SUBSTR([Date], INSTR([Date], '/') + 1) AS INT))
I'm trying to use the above SQLite query to take a date string in the MM/DD/YYYY
format and change it to yyyy-mm-dd
. It's written the way it is to account for the various ways this particular date format can appear (i.e. M/D/YYYY
, M/DD/YYYY
and MM/D/YYYY
)
If I only take 2 segments of the above query (so the month and year, year and day, or day and month), it works. However, when I try to concatenate the entire query above, something breaks and I just get the original date string.
Any idea what is happening?
Thanks,
Edited to clarify