与'01 -01-2011'和'31 -01-2011'之间的date_format(ExpenditureDate,'%d-%m-%Y')相同,
我也无法检查cond与之间,????
ExpenditureDate-DATE类型
在查询下方正确显示,最新日期排在最前面
SELECT ExpenditureName,ExpenditureAmount,ExpenditurePlaceTypeWhome,ExpenditureDate FROM tblexpenditure WHERE Status=1 AND EntryUser=2 ORDER BY ExpenditureDate DESC
但是如果我添加date_format(ExpenditureDate,'%d-%m-%Y')作为ExpenditureDate
然后松开我的正确订单,它会显示有序
SELECT ExpenditureName,ExpenditureAmount,ExpenditurePlaceTypeWhome,date_format(ExpenditureDate,'%d-%m-%Y') as ExpenditureDate FROM tblexpenditure WHERE Status=1 AND EntryUser=2 ORDER BY ExpenditureDate DESC
最佳答案
我没有运行mysql的盒子来进行测试,但我尽量避免将字符串格式的可显示“支出日期”命名为与您排序时使用的相同。
关于mysql - 按日期顺序按问题排序,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/4889129/