Thanks for the input, Rick.
yeah, I know. And I really should have had more information before throwing the question out there. I had assumed I would be pulling from a MySQL database when, as it turned out, the data is coming from an AS400, (the MySQL db comes in later) and I have no control over the originating database structure, so I'm stuck with the separate date and time fields and no way that I know to formulate an iSeries query to combine them.
I was also given erroneous information on the times - rather than ranges, there is simply a start time and end time. (StartTime on the Start Date, EndTime on the End Date)
That still left me with a problem. What I ended up doing is pulling the data according to the date range, then simply excluding anything not in the time range while iterating through the loop.
$DateString = " AND PDATE >= '$SDate' AND PDATE <= '$EDate'";
$OrderField = $Sdate != $EDate ? "PDATE" : "PTIME";
$Q = "SELECT * FROM {ASA400 Table} WHERE PUNIT = '$_POST[PUnit]'".$DateString." ORDER BY ".$OrderField;
$Result = i5_query($Q,$i5_conn);
Then, in the loop:
while($L = i5_fetch_array($Result))
{
if(($L[PDATE] == $SDate && $L[PTIME] < $StartTime) || ($L[PDATE] == $EDate && $L[PTIME] > $EndTime))
{
continue; // In PHP this goes to top of loop
}
-- Remainder of loop code here --
}