Skip to content

Query between dates #594

Closed
Closed
@henriale

Description

@henriale

I noticed a problem when I attempted to get the records between 2 dates, like this:

$month = new Carbon("first day of September");

self::where(function ($query) use ($month) {
    $query->where('date', '>=', $month);
    $query->where('date', '<=', $month->modify('last day of this month'));

    // Also, the condition below returns a empty Collection object 
    //$query->whereBetween('date', [new Carbon("first day of September"), new Carbon("last day of September")]);
})->get();

It returns a empty Collection object, but if I comment any one of the $query lines, it works fine.

I'm running it on Lumen.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions