$rows = Registrant::select(DB::raw('count(*) as number, created_at'))
->whereBetween( DB::raw('date(created_at)'), [$fromDate, $tillDate] )
->groupBy(DB::raw('date(created_at)'))
->get();
以上查询给出了以下结果:
[{"number":4,"created_at":"2017-11-08 17:57:37"}]
这是完全正确的,除了我只想在没有时间的情况下出现约会(17:57:37)?如何删除时间:
[{"number":4,"created_at":"2017-11-08"}]
答案 0 :(得分:1)
简单地替换
DB::raw('count(*) as number, created_at')
与
DB::raw('count(*) as number, DATE(created_at)')