Forum Moderators: coopster & phranque

Message Too Old, No Replies

Querying yesterday

MySQL

         

RussellC

7:34 pm on Apr 14, 2003 (gmt 0)

10+ Year Member



I have been trying to figure out how to query for yesterday.

I have a table that has a DATETIME type. How can I SELECT all of the items from the table that occured yesterday. For some reason I can't figure it out. I know that NOW() - 1000000 will give me the time right now yesterday, but i need all times for the previous day.
If anyone can help it would be much appreciated. Thanks.

DrDoc

7:40 pm on Apr 14, 2003 (gmt 0)

Birdman

7:43 pm on Apr 14, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hello Russel,

How about this method?

SELECT *
FROM table
WHERE time
LIKE '20030313%'

RussellC

7:54 pm on Apr 14, 2003 (gmt 0)

10+ Year Member



Thanks Birdman, but I meant 'Yesterday' dynamically. I figured it out though.

SELECT widget FROM widgets WHERE date = DATE_SUB(CURDATE(), INTERVAL 1 DAY);

Thanks all,