3 messages in com.mysql.lists.bugsCAST(xx AS DATE) incorrect in MySQL 4.1a
FromSent OnAttachments
Joacim Larsson26 Nov 2003 06:15 
Alexander Keremidarski26 Nov 2003 06:42 
Joacim Larsson26 Nov 2003 06:58 
Subject:CAST(xx AS DATE) incorrect in MySQL 4.1a
From:Joacim Larsson (list@icetsystems.se)
Date:11/26/2003 06:15:43 AM
List:com.mysql.lists.bugs

I have a table (temessage) with a column called eme_last_send of type DATETIME. The table in the case below only contain one row with today's date.

I use the CAST function to remove the time fields:

mysql> SELECT CAST(eme_last_send AS DATE),CURRENT_DATE FROM temessage WHERE CAST(eme_last_send AS DATE)<> CURRENT_DATE; +-----------------------------+--------------+ | CAST(eme_last_send AS DATE) | CURRENT_DATE | +-----------------------------+--------------+ | 2003-11-26 | 2003-11-26 | +-----------------------------+--------------+

However, I did NOT expect this row to appear in this query! It seems like CAST(eme_last_send AS DATE) is not the same as CURRENT_DATE?

Workaround:

mysql> SELECT CAST(eme_last_send AS DATE),CURRENT_DATE FROM temessage WHERE LEFT(eme_last_send,10)<>CURRENT_DATE; Empty set (0.00 sec)

mysql>

This should be easily reproducible and I think this is a bug.

-Joacim