嗨,我有一个列名作为日期,它将保存预付款日期。我想提取当月预付款。对于我正在使用的以下代码。
echo $startDate = date($currentYear . "-" . $currentMonth . "-1");
echo $endDate = date($currentYear . "-" . $currentMonth . "-" . $numberOfDaysInMonth);
DB::enableQueryLog();
echo $advances = UserServiceAdvancePayment::where('user_service_master_id', $userServiceMasterObject->id)
->whereDate('date', ">=", $startDate)
->whereDate('date', "<", $endDate)
->get();
当我应用一个日期条件时,我得到了数据,但当应用另一个时,它不会返回数据。也试过和之间也有同样的问题。我们非常感谢对的任何帮助
如果我理解你需要正确地做什么,那么使用Carbon更容易做到:
$startDate = CarbonImmutable::createFromDate($currentYear, $currentMonth, 1)
$endDate = CarbonImmutable::createFromDate($currentYear, $currentMonth, 1)->endOfMonth();
DB::enableQueryLog();
$advances = UserServiceAdvancePayment::where('user_service_master_id', $userServiceMasterObject->id)
->whereDate('date', ">=", $startDate)
->whereDate('date', "<=", $endDate)
->get();