[code]$sql2 = "SELECT start_time, end_time FROM default_ScheduleEvents WHERE (default_ScheduleEvents.aircraft_id = $this_aircraft_id)"; $recordSet2 = $conn->Execute($sql2); if ($recordSet2 === false) { log_error($sql2); } $num_records = $recordSet2->RecordCount(); if ($num_records > 0) { $hours_array = array(); while (!$recordSet2->EOF) { $st_time = strtotime(make_db_unsafe ($recordSet2->fields[start_time]));//start time in unix stamp $en_time = strtotime(make_db_unsafe ($recordSet2->fields[end_time]));//end time in Unix stamp $this_date = DATE("M-d-Y",$st_time); $flight = ($en_time - $st_time)/3600; //Flight time in hours $day_of_week = date("l", $st_time); if(isset($hours_array[$time_slot])){ //...add the current hour value to the //existing value.. $hours_array[$day_of_week] += $flight; } else { //if the name isn't there, then add it and //give it the value of the hours $hours_array[$day_of_week] = $flight; } echo "<tr><td>$day_of_week</td><td>Time of day</td><td>$hours_array[$day_of_week]</td></tr>"; $recordSet2 ->MoveNext(); } // end if number > 0[/code] This is what I have so far. This outputs the total hours scheduled for the day of the week. What I need is a way to take the hours a subdivide them into time of day (i.e. morning, afternoon, evening). The code I have may be no good to do this. The thing to remember is that a reservation might be made between two times, for example a reservation made from 8am to 2pm would be 4 hours in "Morning" and 2 hours in "Afternoon".