I have some data in a flat file that includes a timestamp field that looks like 1900-01-01 00:00:00
. I've been trying to load it into a MySQL table but MySQL is taking it and setting it as 0000-00-00 00:00:00
which is causing issues for me. I've tried running some update
commands on the field, but it stays as 0000-00-00 00:00:00
.
I know of the from_unixtime
function, but how would I use that here? This is the command I'm running to load the data:
load data local infile 'file.txt' into table tgt_table FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '\'' (tbl_name, db_name, timestamp_field, other_col);
The field in question here is timestamp_field
.
I've managed to use from_unixtime
like update tgt_table set timestamp_field=FROM_UNIXTIME('1900-01-01 00:00:00') where tbl_name = 'test';
but timestamp_field ended up looking like: 1969-12-31 18:31:40
Would appreciate any help on how to format either the column or the SQL to get this inserted correctly