sql BETWEEN

Sims, John (CDC/CCHP/NCBDDD) (CTR) ayu8 at cdc.gov
Tue Feb 13 13:36:13 CST 2007


> -----Original Message-----
> From: valentina-bounces at lists.macserve.net 
> [mailto:valentina-bounces at lists.macserve.net] On Behalf Of Stan Busk
> Sent: Tuesday, February 13, 2007 2:29 PM
> To: Valentina Developers
> Subject: Re: sql BETWEEN
> 
> 
> So if it is inclusive BETWEEN has a bug, doesn't it?
> 
Hi Stan,

Possibly not.  Most DBs I've worked with store the "date" as a
"date-time".  When you pass it "01/31/06", you are really passing
something like "01/31/06 00:00:00" so unless you have values in your DB
that are exactly at 12:00 midnight, you don't get anything for that
date.  So, Between is technically inclusive but tough to use on dates.
I would use "02/10/06" as you suggested yourself (though you might get a
record for that date if the time is exactly at midnight).  Personally, I
prefer to use >='01/01/06' and <'02/01/06' as it is just safer.

Take care.

-John


More information about the Valentina mailing list