我必须找到两个日期的差异(日期必须从字符串转换为日期格式)。我正在使用以下 mysql 查询
SELECT DATEDIFF
(
(SELECT STR_TO_DATE(create_date, '%e %b %Y %k:%i') AS create_date FROM booking) AS date1
,
(SELECT STR_TO_DATE(start_date, '%e %b %Y %k:%i') AS start_date FROM booking) AS date2
) diff
单独的内部查询成功地工作。日期格式正确转换,例如从5 Mar 1985 2:33
到1985-03-05 02:33:00