[thelist] mysql: monthname results order
r937 at interlog.com
r937 at interlog.com
Fri Mar 14 13:46:10 CST 2003
> SELECT DISTINCT MONTHNAME(date) AS month
> FROM date
> WHERE (date <> '0000-00-00')
> ORDER BY month ASC
>
> At the moment that returns the months in alphabetical order...
> how can I return them in the correct calender order?
hi dunstan
may i make some suggestions?
do not give the same name to both a table and a column
do not use a reserved word (date) as a table or column name
do not store a "zero date" value -- use null instead
with these in mind, what you want is
select distinct
monthname(thedate) as alphamonth
, month(thedate) as numericmonth
from yourtable
where thedate is not null
order
by month(thedate) asc
rudy
More information about the thelist
mailing list