List:General Discussion« Previous MessageNext Message »
From:Gleb Paharenko Date:October 7 2005 6:09pm
Subject:Re: Between used with date fields
View as plain text  
Hello.

Search in the archives at:
  http://lists.mysql.com/mysql

BETWEEN is meant among other operators at:
  http://dev.mysql.com/doc/mysql/en/using-date.html

But be aware of that when you're using a datetime columns the query:

  SELECT a from b WHERE a BETWEEN '2005-01-01' and '2005-01-03';

is equal to the following one:

  SELECT a from b
  WHERE a BETWEEN '2005-01-01 00:00:00' and '2005-01-03 00:00:00';

And record with a='2005-01-01 19:00:00' won't be included in the result set.


Erfan Shirazi wrote:
> It works fine, no errors and it seems to get correct data but the mysql
> manual and some other books doesn't mention anything about BETWEEN being
> used like this and therefor I'm not completely sure, anybody with any
> experience with my example?
> 
> Erfan Shirazi
> Application Developer, Information Technology - Shipco Transport
> Email: eshirazi@stripped
> Phone: +45 39 15 05 63
> 
> 
> 
> Felix Geerinckx wrote:
> 
>> On 07/10/2005, Erfan Shirazi wrote:
>>
>>  
>>
>>> I have a question about BETWEEN.
>>> Could it be used to look up fields which have a date between to date
>>> fields?
>>>
>>> Ex: '2005-10-07' BETWEEN tEffectivedate AND tExpirationdate
>>>
>>> tEffectivedate and tExpirationdate are DATE types.
>>>   
>>
>>
>> What happened when you tried?
>>
>>  
>>
> 


-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___     ___ ____  __
  /  |/  /_ __/ __/ __ \/ /    Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   Gleb.Paharenko@stripped
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
       <___/   www.mysql.com



Thread
Between used with date fieldsErfan Shirazi7 Oct
  • Re: Between used with date fieldsFelix Geerinckx7 Oct
    • Re: Between used with date fieldsErfan Shirazi7 Oct
      • Re: Between used with date fieldsGleb Paharenko8 Oct
  • Re: Between used with date fieldsFelix Geerinckx7 Oct