In my table I have a varchar column called date containing string representations of dates in dd/mm/yyyy format. How can I convert these to Unix times in a SELECT query?
3 Answers
I think UNIX_TIMESTAMP should do the trick. Can you specify your select query here?
http://dev.mysql.com/doc/refman/5.0/en/date-and-time-functions.html#function_unix-timestamp
1 Comment
Zizo
Here is what I did select unix_timestamp(str_to_date('date','%d/%m/%Y')) from tbl; Where date is column name. And the result is null
SELECT UNIX_TIMESTAMP(date) FROM yourtable. Since you're not storing your dates as dates in the first place, though, there's an extra conversion step (shown in the accepted answer) which makes things just a little more complicated.