I have a field LOREM of type json in my mysql DB table BLAH.
LOREM has a property createdOn which is a date formatted like so: 2020-03-05T04:30:00.000+0000
(This is the value retrieved by running the command:
SELECT LOREM ->>'$.createdOn' FROM BLAH;
)
I'm trying to create a virtual generated column for created on so that querying becomes a little easier. I've tried putting this in the ddl when creating the table:
CREATED_ON timestamp(3) GENERATED ALWAYS AS (CAST(LOREM ->> '$.createdOn' AS DATETIME)) VIRTUAL,
but when inserting an entry I get an error:
1292 Truncated incorrect datetime value: '2020-03-05T04:30:00.000+0000'
I've tried changing the column timestamp precision from 3 to 6, but that didn't work. I've also tried
CREATED_ON timestamp(3) GENERATED ALWAYS AS (TIMESTAMP(CAST(LOREM ->> '$.createdOn' AS DATETIME))) VIRTUAL,
, but got the same error.
Any idea why this may be happening and how I should solve it?