Hello List!
I have a question on how to sort a list of dates after using the convert function on it....
Here's my list of dates:
returns:
2007-11-01 00:00:00.000
2007-10-01 00:00:00.000
2007-09-05 00:00:00.000
2008-01-01 00:00:00.000
2000-01-01 00:00:00.000
2007-12-01 00:00:00.000
I need to pass this to a report in the format MM/DD/YY and in this order:
01/01/08
12/01/07
11/01/07
10/01/07
09/05/07
01/01/00
If I do this:
I get:
12/01/07
11/01/07
10/01/07
09/05/07
01/01/08
01/01/00
If I do this, I get the correct order, but the date is NOT in the right FORMAT:
Results:
2008-01-01 00:00:00.000
2007-12-01 00:00:00.000
2007-11-01 00:00:00.000
2007-10-01 00:00:00.000
2007-09-05 00:00:00.000
2000-01-01 00:00:00.000
How can I get this in the right ORDER and FORMAT???
Any ideas/help would be greatly appreciated!!!
Thanks much!
-jiggyg
I have a question on how to sort a list of dates after using the convert function on it....
Here's my list of dates:
Code:
SELECT DISTINCT runDate
FROM areaEval
returns:
2007-11-01 00:00:00.000
2007-10-01 00:00:00.000
2007-09-05 00:00:00.000
2008-01-01 00:00:00.000
2000-01-01 00:00:00.000
2007-12-01 00:00:00.000
I need to pass this to a report in the format MM/DD/YY and in this order:
01/01/08
12/01/07
11/01/07
10/01/07
09/05/07
01/01/00
If I do this:
Code:
SELECT DISTINCT CONVERT(varchar,runDate,1) AS RunDate
FROM areaEval
ORDER BY RunDate DESC
I get:
12/01/07
11/01/07
10/01/07
09/05/07
01/01/08
01/01/00
If I do this, I get the correct order, but the date is NOT in the right FORMAT:
Code:
SELECT DISTINCT runDate
FROM areaEval
ORDER BY runDate DESC
Results:
2008-01-01 00:00:00.000
2007-12-01 00:00:00.000
2007-11-01 00:00:00.000
2007-10-01 00:00:00.000
2007-09-05 00:00:00.000
2000-01-01 00:00:00.000
How can I get this in the right ORDER and FORMAT???
Any ideas/help would be greatly appreciated!!!
Thanks much!
-jiggyg