I have a DB where a field called date which has a timestamp and i am trying to sort delivery reports for sms.
the incoming delivery report has a timestamp which is normally around 30 seconds out or may be more.
how would i find the closest match to the report timestamp?
SELECT `date`, '2015-06-29 20:03:23' AS SMSTIME FROM history ORDER BY ABS(`date` - SMSTIME) ASC LIMIT 1
does not bring back the correct day or time