----- Original Message -----
From: "Peter Sampson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 15, 2002 9:06 PM
Subject: Simple SQL


> SQL beginner using Macromedia Ultradev. Can you help?
>
> Please be gentle I'm not  a programmer!
>
> I am using
>
> Select DISTINCT Month
> FROM tblNews
>
> The problem is that the months are shown alphabetical not in
> calendar order.
>
> How can I change this?


Perhaps a bit clunky, but if you store dates as "datetime", or "date" type
(recommended anyway), you can simply sort numericly on them by converting
them to unix_timestamp in your query,

"SELECT MONTH(mydate) FROM mydates ORDER BY unix_timestamp(mydate) ASC";

The unix_timestamp is not really necessary here, as you could simply suffice
to say,

ORDER BY MONTH(mydate)

But that was just in illustration how to easily sort on dates. :)

There may be cleverer way to sort on dates, but I find the unix_timestamp to
be very useful for this purpose.

- Mark


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to