Reputation: 105
I have a table of events which includes a field called date
in date
format, so all entries are in the shape of YYYY-MM-DD
.
Is there any simple solution to (batch) convert them all into epoch timestamp, even as a new field (date2
e.g.) as it has to be an int
?
There are around 15000 entries inside this table, so I can't do it manually of course.
Upvotes: 1
Views: 810
Reputation: 311978
The unix_timestamp
function does just that:
ALTER TABLE mytable ADD COLUMN new_date NUMERIC;
UPDATE mytable SET new_date = UNIX_TIMESTAMP(date);
Upvotes: 1