我的表格产品中有这样的字段
--exp_date--
2016-08-02
2016-08-28
2016-08-28
2016-08-23
2016-08-15
2016-08-05
2016-08-20
exp_date
已经在date
mysql 中格式化了
我想要select
数据从今天起剩余的日期exp_date
少于 15
我已经尝试过这样的事情
$dn = date('Y-m-d'); //today date
$query = DB::table('product')->where(DB::raw('datediff(exp_date), $dn') < 15)->get();
但我得到这个错误
Object of class Illuminate\Database\Query\Expression could not be converted to int
如何解决?
ps:
我使用 laravel 4.2 并且更喜欢它是通过查询构建器或原始查询