On 01/31/2011 12:18 PM, Jørn Dahl-Stamnes wrote:
> On Monday 31 January 2011 21:12, Phillip Baker wrote:
>> Greetings All,
>> I am looking for a little help in setting a where clause.
>> I have a dateAdded field that is a DATETIME field.
>> I am looking to pull records from Midnight to midnight the previous day.
>> I thought just passing the date (without time) would get it but I keep
>> getting an empty record set.
>> So looking for something that works a bit better.
> select * from your_table where convert(dateAdded, date)='2011-01-31';
not so good, but it works:
select * from your_table where dateAdded like '2011-01-31%';
select * from your_table where dateAdded between '2011-01-30%' and
select * from your_table where DATE_SUB('2011-01-31', INTERVAL 1 DAY);