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

[5.2] Add where time support query #14528

Merged

Conversation

johnpaulmedina
Copy link
Contributor

@johnpaulmedina johnpaulmedina commented Jul 28, 2016

Added the ability to query with whereTime support for MySQL
#14364

@johnpaulmedina
Copy link
Contributor Author

If this works well how can we push this to 5.3 release?

@fernandobandeira
Copy link
Contributor

5.3 receive merges from the whole 5.2 branch, also 5.2 receives from 5.1 then eventually if this get into 5.2 it will go to 5.3 too...

@jmarcher
Copy link
Contributor

I think that you need to make a few tests to ensure everything works properly

@GrahamCampbell GrahamCampbell changed the title Add where time support query [5.2] Add where time support query Jul 29, 2016
@taylorotwell taylorotwell merged commit 497a7c6 into laravel:5.2 Jul 29, 2016
@johnpaulmedina johnpaulmedina deleted the add-where-time-support-query branch July 29, 2016 17:56
@tillkruss
Copy link
Collaborator

@johnpaulmedina Could you provide 1-2 tests?

@johnpaulmedina
Copy link
Contributor Author

johnpaulmedina commented Jul 30, 2016

It was already merged in. I actually use this on production myself and shared it. I will keep in mind to provide the tests with other contributions next time.

I use it for statistics and metrics on agents in a call center between date x and date y BUT only between time x and time y of each of those dates in the range.

I didn't really write this code. It technically already exist in Laravel framework for whereDay whereYear whereMonth whereDay... all I did was duplicate one of those and change the MySQL function it calls to time().

MyEloquentModel::whereDate('created_at','>=','2016-07-01')
               ->whereDate('created_at','<=','2016-07-28')
               ->whereTime('created_at','>=','22:00:00')
               ->get();

Essentially it is leveraging the database time() function to get things between two dates but only where the timestamps time is greater than 22:00 hours.

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

Successfully merging this pull request may close these issues.

None yet

6 participants