如何使用Laravel Query Builder中的日期(时间轴)

时间:2015-06-08 17:51:05

标签: laravel laravel-5 query-builder

select count(*) from laporan where date(w_laporan) = date(timestamps)

如何在Laravel 5查询构建器中使用此查询? 感谢。

2 个答案:

答案 0 :(得分:0)

您可以尝试这样的事情:

$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

答案 1 :(得分:0)

请尝试以下操作。

using System.Globalization; 

...

decimal myValue = -0.123m;
NumberFormatInfo percentageFormat = new NumberFormatInfo { PercentPositivePattern = 1, PercentNegativePattern = 1 };
string formattedValue = myValue.ToString("P2", percentageFormat); // "-12.30%" (in en-us)