Skip navigation links

MySQL Forums :: PHP :: Query with overall date range and start/end time ranges


Advanced Search

Re: Query with overall date range and start/end time ranges
Posted by: Rational Rabbit ()
Date: April 26, 2012 08:10PM

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 -- 
}

Options: ReplyQuote


Subject Written By Posted
Query with overall date range and start/end time ranges Rational Rabbit 04/23/2012 07:53AM
Re: Query with overall date range and start/end time ranges laptop alias 04/23/2012 08:02AM
Re: Query with overall date range and start/end time ranges Rational Rabbit 04/23/2012 11:23AM
Re: Query with overall date range and start/end time ranges laptop alias 04/23/2012 12:57PM
Re: Query with overall date range and start/end time ranges Rational Rabbit 04/23/2012 07:36PM
Re: Query with overall date range and start/end time ranges Rick James 04/25/2012 09:22PM
Re: Query with overall date range and start/end time ranges Rational Rabbit 04/26/2012 08:10PM
Re: Query with overall date range and start/end time ranges Rick James 05/02/2012 11:24PM
Re: Query with overall date range and start/end time ranges banica derp 05/01/2012 08:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.