List:General Discussion« Previous MessageNext Message »
From:Terence Date:September 10 2003 3:21am
Subject:MySQL 4.1 Date Comparing
View as plain text  
Dear All,

We recently upgraded from 3.23 to 4.1.

We used to use queries such as:

SELECT field FROM table WHERE date_field like '2003-10-10%'

(The date_field is a "datetime" field)

Since we found the performance quicker than using the date functions.

However this no longer works in 4.1, and the only way I can find to do the
above is
SELECT field
FROM table
WHERE YEAR(date_field) = YEAR(curdate())
AND MONTH(date_field) = MONTH(curdate())
AND DAY(date_field) = DAY(curdate())

Is there a better way, since I cant seem to find any functions to return the
date_field to a date.

JFYI, I have tried:

FROM ...
WHERE DATE(date_field) = curdate()

according to the manual > DATE() is available as of MySQL 4.1.1.

FROM ...
WHERE CURRENT_DATE(date_field) = curdate()


MySQL 4.1 Date ComparingTerence10 Sep
  • RE: MySQL 4.1 Date ComparingJon Frisby10 Sep
    • Getting data from multiple databasesScott Haneda10 Sep