1

当前日期时间转换存在问题“xl_date”的日期为 MM/DD/YYYY

示例查询:-

SELECT orders.*, 
  customer.id AS userid, 
  customer.login, 
  convert(datetime, orders.xl_date, 101) as ddates 
FROM orders 
LEFT JOIN customer 
ON orders.userid = customers.id 
WHERE 1 
ORDER BY ddates DESC LIMIT 0, 30
4

1 回答 1

0

您需要使用STR_TO_DATE函数。例如 -

SELECT STR_TO_DATE(orders.xl_date, '%m/%d/%Y') AS as ddates FROM orders

您的查询是 -

SELECT
  orders.*, 
  customer.id AS userid, 
  customer.login, 
  STR_TO_DATE(orders.xl_date, '%m/%d/%Y')as ddates 
FROM orders 
  LEFT JOIN customer 
    ON orders.userid = customers.id 
WHERE
  1 
ORDER BY
  ddates DESC
LIMIT 0, 30
于 2013-02-06T10:46:43.993 回答