[prev in list] [next in list] [prev in thread] [next in thread] 

List:       mysql
Subject:    Re: Help with Date in Where Clause
From:       Bruce Ferrell <bferrell () baywinds ! org>
Date:       2011-01-31 22:57:18
Message-ID: 4D473E4E.2040804 () baywinds ! org
[Download RAW message or body]

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);

-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/mysql?unsub=mysql-marcsub@progressive-comp.com

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic