开发者

mysql sort string as date not as string

The DB I inherited stored there dates like: yyy-mm-dd hh:mm:ss

I was hoping to sort by date in my mysql query but it is treating them like a string and sorting accordingly.

Any one know of a way to sort them as a date and not a string in the query itself?

Thanks, Rob开发者_开发百科ert


You can try casting the value to a date and sorting by that:

ORDER BY CAST(SDate As DATETIME);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜