Wrong result with filter by datetime type

1 post / 0 new
mdobryakov2
mdobryakov2's picture
Offline
Last seen: 4 months 1 week ago
Joined: May 29 2013
Senior Boarder

Posts: 23

Maxim Dobryakov
Wrong result with filter by datetime type

Hello All,

I have a table

[code]
CREATE TABLE `impressions` (
`timestamp` datetime DEFAULT NULL,
`month` varchar(7) DEFAULT NULL,
`day` date DEFAULT NULL,
...
[/code]

month and day fields contains formatted values base on timestamp field.

When I execute the following query it return 8 records:

[code]
select *
from impressions
where (timestamp between '2013-07-08 00:00:00' and '2013-07-08 23:59:59') and storefront = 'sf1'
[/code]

but next query return 112 records:

[code]
select *
from impressions
where storefront = 'sf1' and day = '2013-07-08'
[/code]

All values in timestamp, month and day fields correct (I checked it in last query).

Why the first query return less records then last query? This is looks like a bug.

Thanks