CODE
function callbacks() {
$q = "SELECT contact_info.contact_id,
contact_info.company_name,
contact_info.contact_name,
contact_info.contact_pcs,
contact_info.contact_phone,
contact_info.contact_postcode,
contact_status.status,
contacts.nextaction
FROM contact_info
INNER JOIN contacts
ON contact_info.contact_id = contacts.id
INNER JOIN contact_status
ON contact_status.status_id = contacts.status_id
WHERE (TO_DAYS(contacts.nextaction)) - TO_DAYS(NOW()) <= 1
AND contacts.user_id = 1
LIMIT 50";
$query = $this->db->query($q);
return $query->result_array();
}
$q = "SELECT contact_info.contact_id,
contact_info.company_name,
contact_info.contact_name,
contact_info.contact_pcs,
contact_info.contact_phone,
contact_info.contact_postcode,
contact_status.status,
contacts.nextaction
FROM contact_info
INNER JOIN contacts
ON contact_info.contact_id = contacts.id
INNER JOIN contact_status
ON contact_status.status_id = contacts.status_id
WHERE (TO_DAYS(contacts.nextaction)) - TO_DAYS(NOW()) <= 1
AND contacts.user_id = 1
LIMIT 50";
$query = $this->db->query($q);
return $query->result_array();
}
Okay, What i am trying to do is Select all the records before Todays date, The database has a field (nextaction) that stores a timestamp and i am trying to query the database to pull all of the records where the timestamp is before now.
Now if i put an actual timestamp in the WHERE Caluse, such as..
CODE
WHERE (TO_DAYS(11211134554)) - TO_DAYS(NOW()) <= 1
This returns all the records it should do, although if i try and reference it with the timestamp pulled from the database (contacts.nextaction) it returns no results.
If someone has a better, or a working method of doing the above then i would appreciate any advice you can offer.
Regards,