Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Between

Status
Not open for further replies.

DonP

IS-IT--Management
Jul 20, 2000
684
US
Is MySQL's BETWEEN inclusive? For example, will this give me the whole year of will it be missing a day on either end?

Code:
$TransactionYear = date("Y")."-1-1";
$YearEnd = date("Y")."-12-31";

$DSWhere = "InvoiceDate BETWEEN '".$TransactionYear."' AND '".$YearEnd."'";

Don
Experienced in HTML, Perl, PHP, VBScript, PWS, IIS and Apache and MS-Access, MS-SQL, MySQL databases
 
yes, BETWEEN is inclusive

however, BETWEEN two date values will exclude any datetimes after midnight on the last day

BETWEEN is safe to use with DATE datatype

for DATETIME datatype, you will want to use...

WHERE InvoiceDate >= '2007-01-01'
AND InvoiceDate < '2008-01-01'

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top