【发布时间】:2016-12-27 16:40:37
【问题描述】:
我的表格产品中有这样的字段
--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 已经在 mysql 中以 date 格式
我想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,更喜欢通过查询构建器或原始查询
【问题讨论】:
标签: laravel laravel-4 laravel-query-builder