How to use where date(timeline) in Laravel Query Builder

327 views Asked by At
select count(*) from laporan where date(w_laporan) = date(timestamps)

How can I use this query in Laravel 5 query builder? Thanks.

2

There are 2 answers

0
The Alpha On

You may try something like this:

$someDate = '2015-06-09';
$result = \DB::select(
    \DB::raw("SELECT count(*) as total FROM items WHERE DATE(w_laporan) = :someDate"),
    ['someDate' => $someDate]
);

Check Raw Expression.

0
chanafdo On

Try the following.

DB::table('laporan')
    ->whereRaw('date(w_laporan) = date(?)', [$timestamp])
    ->get();