-1

How can I retrieved records from the database using carbon dates with the specified date range e.g retrieved records from "2014-10-13" to "2015-11-18"? any ideas, help, suggestions, clues, recommendations please?

Juliver Galleto
  • 8,831
  • 27
  • 86
  • 164

1 Answers1

2

You can use the whereBetween method. So, just as an example, lets say you have two Carbon dates.

$earlier = Carbon::yesterday();
$later = Carbon::today();

Model::whereBetween('column', [$earlier, $later])->get();

The first parameter represents the column you are checking. The second parameter is an array of the two dates.

Using the dates in your question, you can generate the carbon dates like this:

$earlier = Carbon::parse('2015-09-11');
$later = Carbon::parse('2015-09-14');

Model::whereBetween('column', [$earlier, $later])->get();

The parse method is pretty awesome.

Thomas Kim
  • 15,326
  • 2
  • 52
  • 42