1 2 3 4 5 6 7 8 9 10 11
| 日期转字符串: 在MySQL中没有to_date函数,进行日期转换需使用date_format()来代替。 select date_format('2013-5-11', 'yyyy-mm-dd') from dual; 在Oracle中的‘yyyy-mm-dd’MySQL下不支持。 select date_format(now(), '%Y-%m-%d') from dual; y和Y不一样。 select date_format(now(), '%Y-%c-%d %h:%i:%s') from dual; c和m、M不一样 所以yyyy-mm-dd hh24:mi:ss格式在MySQL中对应'%Y-%c-%d %h:%i:%s' 字符串转日期: select str_to_date('2013-6-04 05:14:15' , '%Y-%c-%d %h:%i:%s') from dual;
|