I have been beating my head against a wall, trying to get this query to work. I am trying to get results where the "last_modified" DateTime field is within the last hour. I gave up trying the DATE_SUB(DATE(), INTERVAL 1 HOUR
method and am now using Carbon. Either way, I'm only getting results when I set the interval to several days, and none of what returns are what I'm looking for. In addition, I have data with a DateTime stamp from very recently.
Code
$day_ago = Carbon::now()->subDays(1)->format('Y-m-d');
$sql = "SELECT appt_id, provider_id, start_datetime, end_datetime,
added_zen, appt_notes, pt_fname, pt_lname, conf_status,
last_modified, zen_block_out_time_id
FROM appointments WHERE is_del = 0 AND (
zen_block_out_time_id IS NOT NULL AND (last_modified < ($day_ago))
AND location_id = 2) ORDER BY start_datetime ASC";