List:General Discussion« Previous MessageNext Message »
From:Bruce Ferrell Date:January 31 2011 10:57pm
Subject:Re: Help with Date in Where Clause
View as plain text  
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%';

OR
select * from your_table where dateAdded between '2011-01-30%' and
'2011-01-31%';


better:

select * from your_table where DATE_SUB('2011-01-31', INTERVAL 1 DAY);
Thread
Help with Date in Where ClausePhillip Baker31 Jan
  • Re: Help with Date in Where ClauseJørn Dahl-Stamnes31 Jan
    • Re: Help with Date in Where ClausePhillip Baker31 Jan
    • Re: Help with Date in Where ClauseBruce Ferrell31 Jan
  • Re: Help with Date in Where ClauseMySQL)31 Jan