SELECT sum(AfterDiscount) AS
AfterDiscount,DATE_FORMAT(UpdateDate,'%d-%m-%Y')
as UpdateDate FROM tblsale where
date_format(UpdateDate,'Y-m-d')=date_format(now(),'Y-m-d')
AND BillType='s'
此查询今天呈现第28条记录,
我希望按今天的日期呈现记录
问题已解决,
SELECT sum(AfterDiscount) AS
AfterDiscount,DATE_FORMAT(UpdateDate,'%d-%m-%Y')
as UpdateDate FROM tblsale where
date_format(UpdateDate,'%Y-%m-%d')=date_format(now(),'%Y-%m-%d') AND BillType='s'
答案 0 :(得分:4)
为什么不比较WHERE DATE(UpdateDate)=CURRENT_DATE()
?为什么要格式化呢?
修改强>
此处的其他功能:http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date