2016-09-16 24 views
-1

我有一个日期字段ref_event_timesend_date和一个时间字段ref_event_timesend_time我的表 “ref_event_times” ......来自CONCAT的STR_TO_DATE

我试图工会,作为一个日期时间字段 “END_DATE_TIME” ...... 使用遵循

STR_TO_DATE('CONCAT(`ref_event_times`.`end_date`,' ',`ref_event_times`.`end_time`)','%m/%d/%Y %H:%i') AS `end_date_time` 

返回NULL ...

在哪里是错误的?

+0

尝试'STR_TO_DATE(CONCAT( ref_event_times.end_date,'',ref_event_times.end_time),'%m /%d /%Y%H:%i')'这一个 –

+0

尝试这个我检查了它的WO RKING select STR_TO_DATE(CONCAT(current_date,'',current_time),'%Y-%m-%d%H:%i:%s'); – JYoThI

+0

STR_TO_DATE(CONCAT('ref_event_times'.''end_date','','','ref_event_times'.'end_time'),'%Y-%m-%d%H:%i:%s') 最终需要' Y-%m-%d%H:%i:%s' More thanks –

回答

0

MySQL不支持您定日期时间格式'%m/%d/%Y %H:%i'

MySQL的日期格式应该是这样的'%Y-%m-%d %H:%i:%s'Datetime format in mysql

Data Type “Zero” Value 
    DATE  '0000-00-00' 
    TIME  '00:00:00' 
    DATETIME '0000-00-00 00:00:00' 
    TIMESTAMP '0000-00-00 00:00:00' 
    YEAR  0000 

尝试这个例子

select STR_TO_DATE(CONCAT(current_date,' ',current_time),'%Y-%m-%d %H:%i:%s');