[SOLVED]Order by dates...
Posted: Fri Sep 22, 2006 10:13 am
I am trying to bring back the data from my database in order of the starting date and ending date.. however, I am not able to do so. This is my query:
and this is the result that I get:
as you can tell, Apr 14, 2007 comes after Dec 23, 2006. Is there a glaring error in my sql statement?
here is the make up of the table:
Any thoughts would be great. Thanks.
Code: Select all
select num, DATE_FORMAT(startDate,'%b %e, %Y') as startDate, DATE_FORMAT(endDate, '%b %e, %Y') as endDate, reason from exceptionDates order by startDate, endDate;Code: Select all
+-----+--------------+--------------+------------------+
| num | startDate | endDate | reason |
+-----+--------------+--------------+------------------+
| 9 | Apr 14, 2007 | Apr 14, 2007 | Special Closing |
| 6 | Dec 23, 2006 | Dec 29, 2006 | Christmas Break |
| 7 | Dec 30, 2006 | Jan 1, 2007 | new year's break |
| 8 | Mar 2, 2007 | Mar 11, 2007 | spring break |
| 4 | Nov 10, 2006 | Nov 12, 2006 | veteran's day |
| 5 | Nov 21, 2006 | Nov 26, 2006 | thanksgiving |
| 3 | Oct 6, 2006 | Oct 10, 2006 | Fall Break |
| 2 | Sep 1, 2006 | Sep 4, 2006 | Labor Day |
+-----+--------------+--------------+------------------+here is the make up of the table:
Code: Select all
+-----------+----------+------+-----+---------+----------------+| Field | Type | Null | Key | Default | Extra |
+-----------+----------+------+-----+---------+----------------+
| num | int(11) | | PRI | NULL | auto_increment |
| startDate | date | YES | | NULL | |
| endDate | date | YES | | NULL | |
| reason | char(25) | YES | | NULL | |
+-----------+----------+------+-----+---------+----------------+