[snip]
Really what you are trying to do is search on month + day, not a date. 
For special "dates" (birthday, anniversary, etc), I always store the 
year separately. Especially since some people don't really want you to 
know how old they are.

Without breaking the "date" up into it's separate parts, you can't use 
an index, so you will always do a full table scan. Your searches will 
get slower as you add more records.   I don't know how many records you 
are searching on in your example, but if you have a lot, the difference 
is pretty minimal and may be due to slightly different loads on the 
computer. Although the DATE_FORMAT one has the extra overhead of 
formating every single record to do the comparison.
[/snip]

So if I index a date field (given yyyy-mm-dd) and then

SELECT `userNames`
FROM `userTable`
WHERE SUBSTRING(`userBirthDate`, 6, 5) = SUBSTRING(NOW(), 6, 5)

it is still very fast. I have a table with several thousand records in
it and I get back ...

30 rows in set (0.00 sec)

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

Reply via email to