Hope you all are doing well. Actually i am struggling with a minor issue. I am trying to fetch the closest record of if date not matched in database. But somehow it is not working or you can say giving me the wrong information.
After research of 2-3 days. My Jira ticket is move to done and get back to me again. So i need your help to fix this problem. Below is my code that you can check and help me to find the bug.
$atg = @DB::table('mc_atginfo')
->where('SiteId', Input::get('siteId'))
->where('TankId', Input::get('tankId'))
->orderByRaw('ABS(TIMESTAMPDIFF(SECOND, ATGDateTime,?))', [$inputDateTimeFormatted])
->orderBy('ATGDateTime', 'desc')
->first();
return Response::json($atg);
}
Any solution appreciated!