Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dates in between excluding weekends or selected weekdays #54

Open
hasajacykacperek opened this issue Feb 27, 2024 · 3 comments
Open

dates in between excluding weekends or selected weekdays #54

hasajacykacperek opened this issue Feb 27, 2024 · 3 comments

Comments

@hasajacykacperek
Copy link

Can the author add an exclude option to the between function so that I can enter which days of the week (weekends) are excluded from the data? The trend is a good form of data collection, but I don't know how I could exclude non-working days from my chart.

Zrzut ekranu 2024-02-27 o 21 16 06
Zrzut ekranu 2024-02-27 o 21 16 19

@seansch
Copy link

seansch commented Mar 16, 2024

I'm curious about this as well, I have daily data that isn't updated on the weekends so my charts looks similar to yours.

@seansch
Copy link

seansch commented Mar 16, 2024

I realized that Trend::model returns a Laravel collection and can be filtered, so I used a filter like this:

$data = $data->filter(function ($item) {
    return $item->aggregate > 0;
})->values();

Make sure you add values() to the end of your filter so it re-indexes the array keys(I fought with that for a while).

@TwilightDuck
Copy link

You can use the ::query() function to add SQL WHERE clause to filter out the weekends.
DAYOFWEEK(booked_date) <> 1 AND DAYOFWEEK(booked_date)<>7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants