Shannon,
This doesn't directly address your question but I believe you have a bug in your statement. Given the data example you have you will have issues with your date range if it is truly in MM/DD/YYYY format. For example, if you wanted records crossing a year end your end date is less than your start date.
We have a lot of dates like this and had to create a user defined function to convert them to ISO for comparison. It can be done without the UDF but it's pretty ugly.
Rick
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Shannon ODonnell
Sent: Wednesday, January 13, 2010 10:15 AM
To: 'Web Enabling the AS400 / iSeries'
Subject: [WEB400] SQL Date Range
I want to select a group of dates based on date range in a PHP app from a MySQL database.
Assume the table name is xmittalheader and the date field is named:
XMittalDate and is in the format in the MySQL table like this: 11/02/2009
Further assume $startDate and $endDate are being brought into the PHP via a POST from a form.
Would this be the correct syntax?
$results = mysqli_query($db, "SELECT * FROM xmittalheader WHERE XMittalDate BETWEEN ".$startDate." and ".$endDate);
Thanks!
Shannon O'Donnell
--
This is the Web Enabling the AS400 / iSeries (WEB400) mailing list To post a message email: WEB400@xxxxxxxxxxxx To subscribe, unsubscribe, or change list options,
visit:
http://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives at
http://archive.midrange.com/web400.
Privileged and Confidential. This e-mail, and any attachments there to, is intended only for use by the addressee(s) named herein and may contain privileged or confidential information. If you have received this e-mail in error, please notify me immediately by a return e-mail and delete this e-mail. You are hereby notified that any dissemination, distribution or copying of this e-mail and/or any attachments thereto, is strictly prohibited.
As an Amazon Associate we earn from qualifying purchases.