Which database are you using?
I will assume it is MySQL. Try changing the ->groupBy(...) by one of these:
->groupByRaw('CAST(recordtime AS DATETIME)')
or
->groupByRaw('CAST(recordtime AS DATE)') // if you want to group only by date
or
->groupByRaw("DATE_FORMAT(recordtime, '%Y-%m-%d %H:%i:%s')")
For each case you'll also need to change the first selectRaw to match the group by, for example if you chose the last option:
$students = MeasCanal::whereBetween('recordtime', $dateScope)
->selectRaw("DATE_FORMAT(recordtime, '%Y-%m-%d %H:%i:%s') AS recordtime")
->selectRaw('max(formattedvalue) filter (where fullname = \'Данни.Кота\') as kota')
->where(function ($query) {
$query->where('fullname', 'like', "Данни.Кота")
->orWhere('fullname', 'like', "Данни.Напрежение")
->groupByRaw("DATE_FORMAT(recordtime, '%Y-%m-%d %H:%i:%s')")
->orderBy('recordtime')
->get();
return response()->json($students);
}
Reference on DATE_FORMAT: https://dev.mysql.com/doc/refman/8.0/en/date-and-time-functions.html#function_date-format