Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I'm a bit confused on how to order by date formats.

(我对如何按日期格式排序有些困惑。)

For the format YYYY-MM-DD you would do this: ...ORDER BY date DESC...

(对于YYYY-MM-DD格式,您可以执行以下操作: ...ORDER BY date DESC...)

How would you order by DD/MM/YYYY ?

(您如何按DD/MM/YYYY订购?)

This isn't working:

(这不起作用:)

SELECT * FROM $table ORDER BY DATE_FORMAT(Date, '%Y%m%d') DESC LIMIT 14
  ask by Karl Morrison translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
489 views
Welcome To Ask or Share your Answers For Others

1 Answer

Guessing you probably just want to format the output date?

(猜猜您可能只想格式化输出日期?)

then this is what you are after

(那就是你所追求的)

SELECT *, DATE_FORMAT(date,'%d/%m/%Y') AS niceDate 
FROM table 
ORDER BY date DESC 
LIMIT 0,14

Or do you actually want to sort by Day before Month before Year?

(还是您实际上想按年份前一个月的前一天排序?)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...