On Fri, 2004-04-16 at 14:09, Dirk Bremer (NISC) wrote:
> ----- Original Message ----- 
> From: "Victor Pendleton" <[EMAIL PROTECTED]>
> To: "'Dirk Bremer (NISC) '" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
> Sent: Friday, April 16, 2004 15:57
> Subject: RE: SQL Query Question
> 
> 
> > If your data is stored in the following format
> > 2004-04-16 00:00:00
> > you can do WHERE queue_time = CURRENT_DATE() + 0
> > You will also be able to take advantage of an index.
> > ....
> > Else, if you data is kept in the datetime format,
> > 2004-04-16 15:53:27
> > one option is to do
> > WHERE DATE_FORMAT(queue_time, '%Y%m%d') = CURRENT_DATE() + 0
> > ...no index usage though
> 
> 
> Victor,
> 
> The data defined as a timestamp, i.e. a number rather than a string, so it
> has YYYYMMDDHHMMSS values. So it looks like I'll need to do some type of
> substring on it.

You could keep any index you have and do it this way:

    SELECT a,b FROM x WHERE queue_time BETWEEN date_format(curdate(),
"%Y%m%e000000") AND date_format(curdate(), "%Y%m%e235959");


-- 

 |- Garth Webb       -|
 |- [EMAIL PROTECTED] -|

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to