Hi, I have this table for events : 2 Rows: start_date field - datetime: 1.---> 2008-11-22 16:17:10 2.---> 2008-11-20 12:14:16 Using this: SELECT title, DAY(start_date) AS `myD` , MONTH(start_date) AS `MyM` , YEAR(start_date) AS `myY` FROM `events` WHERE 'myD' = '20' PHP: Does not return any!! But SELECT title, DAY(start_date) AS `myD` , MONTH(start_date) AS `MyM` , YEAR(start_date) AS `myY` FROM `events` WHERE 'myD' > '20' PHP: Return the two rows. Using SELECT title, DAY(start_date) AS `myD` , MONTH(start_date) AS `MyM` , YEAR(start_date) AS `myY` FROM `events` WHERE 'myD' >= '20' AND 'myD' < '21' PHP: Return nothing too! How can I get just the rows that are from TODAY!?? I assume 20 - to be today day... Its mssing month , year.. etc.. Could you please help me on this? Thanks.
Try: SELECT title, DAY(start_date) AS myD, MONTH(start_date) AS MyM, YEAR(start_date) AS myY FROM events WHERE DAY(start_date) = 20 AND MONTH(start_date) = 11 AND YEAR(start_date) = 2008
This is a very resource consuming query, I saw this once on 200k rows table running for 30 seconds. Try: SELECT title, DAY(start_date) AS myD, MONTH(start_date) AS MyM, YEAR(start_date) AS myY FROM events Where Date(start_date) = CURDATE()