Dusan
Dusan

Reputation: 276

MySQL select by date range query - unexpected output

Why MySQL in following query:

select * from `tips` 
where `tips`.`tipster_id` = '16' 
and `result` <> '0' 
and `date` >= '2014-02-01' 
and `date` <= '2014-02-28'

excludes rows with date 2014-02-28 ???

Upvotes: 0

Views: 51

Answers (2)

Oleksii Golub
Oleksii Golub

Reputation: 161

I use this version

select * from `tips` 
where `tips`.`tipster_id` = '16' 
and `result` <> '0' 
and `date` >= '2014-02-01 00:00:00' 
and `date` <= '2014-02-28 23:59:59'

Upvotes: 1

Dirk Huber
Dirk Huber

Reputation: 912

Do you store time values in that column? I guess that 2014-02-28 is this is the same as 2014-02-28 00:00:00.

So date values with a time after 00:00:00 will not be included.

Upvotes: 2

Related Questions