duanli9930 2014-08-25 16:56
浏览 35

从数据库中检索日期[关闭]

i got a release_date row in my database now i want too display the latest date on top

my query now:$sql = "SELECT * FROM games ORDER BY release_date ASC";

but this ORDER BY just get the first digits (day) of the date Now i get:

03-11-2014 12-11-2013 14-07-2011 16-03-2012

it needs to be:

03-11-2014 12-11-2013 16-03-2012 14-07-2011

  • 写回答

3条回答 默认 最新

  • dongzhoulong1797 2014-08-25 17:01
    关注

    Use STR_TO_DATE to turn your date string into a real date.

    SELECT * FROM games 
    ORDER BY STR_TO_DATE(release_date, '%d-%m-%Y') DESC
    

    You can also use this function to refomat your date into the default format and then change the column data type to date.

    评论

报告相同问题?

悬赏问题

  • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
  • ¥20 Java-Oj-桌布的计算
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路