On 3 Feb 2003, at 13:58, Stefan Hinz, iConnect (Berlin wrote:

> You could use the DATE_FORMAT() function of MySQL for this:
> 
> mysql> SELECT DATE_FORMAT(NOW(),'%M');
> +-------------------------+
> | DATE_FORMAT(NOW(),'%M') |
> +-------------------------+
> | February                |
> +-------------------------+
> 
> You can't compare this with something like 'January', though, because
> 'January' is a string while the above result is a date. If your query
> string has 'month=January', this is a design problem, and you will
> have to use a bit of array magic to convert your string into a date
> for comparison. Someone slap me if there is an easy way _in MySQL_ to
> accomplish this.

Slap!  The DATE_FORMAT() function returns a string that can be 
compared just like any other string, so a query containing

    DATE_FORMAT(date_column, '%M') = 'January'

should work as expected, as far as I can tell.  But I agree with you 
that having "month=January" rather than "month=1" is probably not the 
ideal design.

-- 
Keith C. Ivey <[EMAIL PROTECTED]>
Tobacco Documents Online
http://tobaccodocuments.org
Phone 202-667-6653

---------------------------------------------------------------------
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