> When I run a query that has a timestamp field, How can I query on just the > date. Time stamp puts in the min, hour, and sec. All I need is the year, > month, and day. > > SELECT * FROM table_name WHERE date = '2003-08-25';
select * FROM table_name WHERE DATE_FORMAT(date,'%Y-%m-%d') = '2003-08-25 or select * FROM table_name WHERE LEFT(date,8) = '20030825' or select * FROM table_name WHERE date LIKE '20030825%' or select * FROM table_name WHERE TO_DAYS(date) = TO_DAYS('2003-08-25') or select * FROM table_name WHERE DAYOFMONTH(date) = '25' AND MONTH(date) = '08' AND YEAR(date) = '2003' or select * from table_name WHERE date between '20030825000000' AND '20030825235959' (check the range on this, I don't use it so it might be wrong '20030826000000' might be better) Some are quicker than others, I'm just demonstrating that there's a lot of different ways to do it, mysql has a lot of built in functions to deal with date/time values. I'm sure I missed a few ways. All the date and time functions can be found in the manual http://www.mysql.com/doc/en/Date_and_time_functions.html -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]