标签: mysql datetime
我正在尝试在查询中使用'date_trunc'函数,它返回以下错误
FUNCTION database.date_trunc不存在。
请咨询
答案 0 :(得分:0)
您可以使用DATE_FORMAT(created_at ,'%Y-01-01')获取一年的第一天:
DATE_FORMAT(created_at ,'%Y-01-01')
SELECT DATE_FORMAT(created_at ,'%Y-01-01') AS `year`, COUNT(*) AS cnt FROM sales_order GROUP BY DATE_FORMAT(created_at ,'%Y-01-01') ORDER BY `year`;
DATE_TRUNC。
DATE_TRUNC