-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Actually, it's not working quite as perfect as I thought.  When using
ASC, it works fine, but when using DESC for sort order, it's quirky.

For example, in ASC mode, it orders like this:
Sep 28, 2003
Oct 05, 2003
Dec 06, 2003
Dec 31, 2003
Jan 02, 2004
Jan 10, 2004
Jan 14, 2004

That's perfect, but in DESC mode, it orders like this:
Sep 28, 2003
Oct 05, 2003
Dec 31, 2003
Dec 06, 2003
Jan 14, 2004
Jan 10, 2004
Jan 02, 2004

It just orders the dates descending within their respective months, but
it doesn't order DESC by year or month.  I figured out how to fix it,
though.  I just placed DESC after each item listed in the ORDER BY.




Ben Ramsey wrote: | Works perfectly! Thanks! | | Roger Baklund wrote: | | Yes, it can be done using the FIELD() function: | | | | SELECT * FROM tablename | | ORDER BY | | MID(datecol,8), # year | | FIELD(LEFT(datecol,3), # month | | 'Jan','Feb','Mar','Apr','May','Jun', | | 'Jul','Aug','Sep','Oct','Nov','Dec'), | | MID(datecol,5,2); # day | | | | <URL: http://www.mysql.com/doc/en/String_functions.html#IDX1185 > | | | -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (MingW32) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFAEAqlIcIs3CP5DxwRAhh4AJ9p0maCDE+Lc9HM3a3vb5p3XjqLcACeJsx0
1tQS3OslXlmBQITYE57NIHU=
=eLqZ
-----END PGP SIGNATURE-----

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to