开发者

Convert dd/mm/yyyy string to Unix timestamp in MySQL

开发者 https://www.devze.com 2023-03-09 19:18 出处:网络
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 Un开发者_如何学编程ix times in a SELECT query?select unix_ti

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 Un开发者_如何学编程ix times in a SELECT query?


select unix_timestamp(str_to_date('30/05/2011','%d/%m/%Y'));

or:

select unix_timestamp(str_to_date(myfield,'%d/%m/%Y')) from mytable;


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


just use unix_timestamp function

0

精彩评论

暂无评论...
验证码 换一张
取 消