我在数据库中将日期存储为VARCHAR时犯了一个错误,这里看起来像 02 / 12/2018 strong>我创建了一个使用碳的变量来获取当前日期 +14天 strong>。 p>
问题是 strong> p>
我正在尝试 比较这个日期 02/12/2018 strong>,它在数据库中并存储为VARCHAR到我使用Carbon生成的日期 09/04/2017 strong>。 p>
Eloquent Code strong> p>
我得到了什么 strong> p>
它没有得到任何结果,因为它比较 只有 required_date strong>中的日期和碳日期 strong>中的日期。 p>
虽然它应该返回值,因为它超过了 1年的差异? p>
div> $ current_date_plus_14 = Carbon: :now() - > addDay(14) - > 格式('d / m / Y'); code> p>
$ gquery = Client :: where('required_date','> =', $ current_date_plus_14) - > get(); code> p>
I have made a mistake by storing the date as VARCHAR in the database and here it looks like 02/12/2018 and I have created a variable using carbon to get the current date +14 days.
$current_date_plus_14 = Carbon::now() -> addDay(14) -> format('d/m/Y');
Problem is
I am trying to compare this date 02/12/2018 which is in the database and stores as VARCHAR to the date that I have generated using Carbon which is 09/04/2017.
Eloquent Code
$gquery = Client::where('required_date', '>=', $current_date_plus_14) -> get();
What I get
It doesn't get any results because it compare only the day in the required_date and the day in the carbon date.
While it should return value because the there is more than 1 year difference?