答案 0 :(得分:1)
这可能会对你有用:
DB::table('emp')
->select(DB::raw("MIN(`time`) AS `time_in`, MAX(`time`) AS `time_out`"))
->where('date', '2017-06-13')
->get();
输出:
{
time_in: "19:38:33",
time_out: "22:14:10"
}
答案 1 :(得分:0)
尝试以下代码:
$attendancehours = DB::select(
DB::RAW('TIMESTAMPDIFF(HOUR,CONCAT(in_date," ",in_time),CONCAT(out_date," ",out_time)'))->
table('staff_attendances')->
whereBetween('in_date', array($date1, $date2))->
where('id', $sID)
->get();
答案 2 :(得分:0)
您可以按日期和时间列订购表格,然后使用Eloquent使用 - > first()和 - > last()使用这些方法。
$collection = BiometricsAttendance::where('emp_id', $emp)->whereBetween('date', [$start, $end])->groupBy('date')->orderBy('time', 'asc');
$timein = $collection->first();
$timeout = $collection->last();