Friday, March 30, 2018

laravel query whereBetween doesn’t work [duplicate] - development

laravel query whereBetween doesn’t work [duplicate]

This question already has an answer here:

Here is my Laravel query.

$fromdate = '2018-04-09';
$todate = '2018-04-28';
$dt = array($fromdate, $todate);
return DB::table('leaves')
  ->select('leaveId')
  ->whereBetween('from', [$dt[0], $dt[1]])
  ->orWhereBetween('to', [$dt[0], $dt[1]])
  ->get();

my db rows

'11', 'ckkl;kghhjgkgvjkvvb,,kkkkhhhhh', '2018-03-29', '2018-04-21', '2018-04-22', 'Sam User', NULL, '2018-03-29 10:52:48', '2018-03-29 10:52:48', '2', '8', '1'
'10', 'pjp'', '2018-03-29', '2018-04-11', '2018-04-12', 'test user', NULL, '2018-03-29 10:50:28', '2018-03-29 10:50:28', '1', '8', '1'

It seems it doesn’t check the whereBetween clause. It only returns leaveId. Thanks for your suggestions.



from Laravel Questions and Answers https://laravelquestions.com/php/laravel-query-wherebetween-doesnt-work-duplicate/
via Lzo Media

No comments:

Post a Comment