2

I've been racking my brains over this one, I can't work it out. I'm trying a new way to show a date on my site (%D %W) for easier reading, but in the process it's knocked all my "ORDER by" out of sync, so instead of:

8th Friday
9th Saturday
10th Sunday
11th Monday

I'm getting

10th
11th
8th
9th

Now I understand why it's displaying it like it is, but I just don't know the correct way to implement the ORDER by statement, this is what I had before:

SELECT *, DATE_FORMAT(date,'%D %W') AS `Date` 
FROM employees WHERE type = 'blah' 
ORDER BY `Date` ASC, `time` ASC

Any ideas? Probably an easy one for some.

4

1 回答 1

1

保留原始日期进行排序并使用“友好日期”进行显示,如下所示:

SELECT *, DATE_FORMAT(date,'%D %W') AS FormattedDate FROM employees WHERE type = 'blah' ORDER BY Date ASC, time ASC
于 2013-03-10T00:04:56.537 回答