RE: Bug in BETWEEN same DATETIME

2013-05-29 Thread Rick James
t; Sent: Friday, May 24, 2013 11:08 AM > To: mysql@lists.mysql.com > Subject: Re: Bug in BETWEEN same DATETIME > > >>>> 2013/05/24 09:49 -0400, shawn green >>>> > Or we could coerce datetime values back to their date values when both > are being used. The

Re: Bug in BETWEEN same DATETIME

2013-05-24 Thread hsv
2013/05/24 09:49 -0400, shawn green Or we could coerce datetime values back to their date values when both are being used. The trick now becomes choosing between rounding the datetime value (times past noon round to the next date) or do we use the floor() function all the time. <<<

Re: Bug in BETWEEN same DATETIME

2013-05-24 Thread shawn green
Hi Rick, Thank you for continuing this. It brings up a few good points. On 5/24/2013 12:17 PM, Rick James wrote: For years (even decades), I have stayed out of trouble by assuming a 'date' represents the instant in time corresponding to midnight at the start of that day. In MySQL (until 5.6)

RE: Bug in BETWEEN same DATETIME

2013-05-24 Thread Rick James
g event, an appointment (potentially in a diff timezone), train schedule, etc. > -Original Message- > From: shawn green [mailto:shawn.l.gr...@oracle.com] > Sent: Friday, May 24, 2013 6:50 AM > To: mysql@lists.mysql.com > Subject: Re: Bug in BETWEEN same DATETIME > >

Re: Bug in BETWEEN same DATETIME

2013-05-24 Thread shawn green
Hello Rick, On 5/23/2013 7:08 PM, Rick James wrote: Watch out for CAST(), DATE(), and any other function. In a WHERE clause, if you hide an indexed column inside a function, the index cannot be used for optimization. INDEX(datetime_col) ... WHERE DATE(datetime_col) = '2013-01-01' wi

Re: Bug in BETWEEN same DATETIME

2013-05-23 Thread Andrew Moore
Personally I don't share your view that it's a bug. Omitting the time results in midnight by default so this screws between because there's no time between 00:00:00 and 00:00:00. Are you having operational issues here or are you simply fishing for bugs? WHERE `transaction_date` = DATE(datetime)

RE: Bug in BETWEEN same DATETIME

2013-05-23 Thread Peterson, Timothy R
You probably want where cast(transaction_date as date) BETWEEN '2013-04-16' AND '2013-04-16' That works on my test case You could also change the where clause to be >= date and < date+1 -Original Message- From: Daevid Vincent [mailto:dae...@daevid.com] Sent: Thursday, May 23, 2

Re: Bug in BETWEEN same DATETIME

2013-05-23 Thread Michael Dykman
>> where cast(transaction_date as date) BETWEEN '2013-04-16' AND This approach might be problematic in that it requires that every row in the source table be examined so that it's transaction_date can be casted. The original formulation is more efficient as it allows an index on transactio

Re: Bug in BETWEEN same DATETIME

2013-05-23 Thread shawn green
On 5/23/2013 4:55 PM, Daevid Vincent wrote: I just noticed what I consider to be a bug; and related, has this been fixed in later versions of MySQL? We are using: mysql Ver 14.12 Distrib 5.0.92, for portbld-freebsd8.1 (amd64) using 5.2 If you use BETWEEN and the same date for both parts (i.

RE: Bug in BETWEEN same DATETIME

2013-05-23 Thread Rick James
iginal Message- > From: shawn green [mailto:shawn.l.gr...@oracle.com] > Sent: Thursday, May 23, 2013 3:50 PM > To: mysql@lists.mysql.com > Subject: Re: Bug in BETWEEN same DATETIME > > > > On 5/23/2013 4:55 PM, Daevid Vincent wrote: > > I just noticed what I

RE: Bug in BETWEEN same DATETIME

2013-05-23 Thread Rick James
he same starting date. > -Original Message- > From: Michael Dykman [mailto:mdyk...@gmail.com] > Sent: Thursday, May 23, 2013 2:56 PM > To: MySql > Subject: Re: Bug in BETWEEN same DATETIME > > >> where cast(transaction_date as date) BETWEEN '2013-04-16&#x

Re: Bug in BETWEEN same DATETIME

2013-05-23 Thread Andrew Moore
Sorry, that was meant to be; WHERE (new column stored as date) = '2013-04-16' On Thu, May 23, 2013 at 10:16 PM, Andrew Moore wrote: > Personally I don't share your view that it's a bug. Omitting the time > results in midnight by default so this screws between because there's no > time between