I need some help with filtering an array on date.
The query below will print a table with all entry's ever. But i wan't to filter on date. If for example today is '30-12-2014' i want to show all entry's from 30-12-2014 and "newer" and not from the first entry thats older then '30-12-2014'.
The "appointment.start_time" is a varchar2 with an output like: 2014-11-28T15:35:00
In the $stid i trim the "appointment.start_time" with substr so the output is like "2014-11-28".
But how do i put the filter in?
Something like this?
foreach ($row as $item)
if ($item->dateitem >= $startDate &&
$item->dateitem <= $endDate)
$newarray[] = $item;
Can you help me please?
Kind regards, Ritchie
--------------------------------------------------- query php ----------------------------------------------------------
$stid = oci_parse($conn, "select
customer.first_name as VOORNAAM,
customer.last_name as ACHTERNAAM,
substr(appointment.start_time,1,10) as DATUM,
substr(appointment.start_time,12,10) as STARTTIJD,
service_definitions.external_name as PRODUCT,
appointment.resource_name as AGENDA
from appointment
inner join appointment_customer on appointment.id = appointment_customer.appointmentjpa_id inner join customer on customer.id = appointment_customer.customerids
inner join appointment_service on appointment_service.appointment_id = appointment.id inner join service_definitions on service_definitions.id = appointment_service.service_id order by appointment.start_time asc ");
oci_execute($stid);
while ($row = oci_fetch_array($stid, OCI_ASSOC+OCI_RETURN_NULLS)) {
echo " < tr > \n ";
foreach ($row as $item)
{
echo "< td >" . ($item !== null ? htmlentities($item, ENT_QUOTES) : " ") . "< /td >\n";
}
echo "< /tr >\n";
------------------------------ SOLVED WITH QUERY ----------------------------------
Hi there all, I solved my problem by adding the following in the query:
where substr(appointment.start_time,1,10) >= TO_CHAR(SYSDATE, 'YYYY-MM-DD')
@krishna put me on the right track. I know that there are more and better ways to handle this but for me its working fine with this.
Thanks all for the help. Regards Ritchie