简体   繁体   中英

MySql 'Order by Date' Question

Im pulling data from a MySql data table. I'm pulling from a row called 'PubDate' (meaning Published date). This format is in Date format, not DateTime. When I execute the query

Select * from Articles order by pubDate ASC

Its ordered by date as so:

1.09/18/09 2.09/18/09 3.09/19/09 4.09/20/09

If possible I would like to be able to get the most recent date first by using the 'ASC' value for direction due to my current code logic. I've already tried

Select * from Article order by Cast(pubdate as datetime) ASC 

but didn't change the output. I CAN do DESC (descending order) if I must...but its not preferable.

the most recent date first

For this you must use DESC .

if you want your newest articles to be first use DESC . default is ASC so there is no point in explicitely adding it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM