public function scopeEventsForDay($query, $fetch_date) {
return $query->where('event_date', 'LIKE', $fetch_date . '%')->orderBy('event_date', 'asc'));
}
Jul 13, 2016
4
Level 1
Trying to query all records for specific date - whereBetween not working?
My Scope:
public function scopeEventsForDay($query, $fetch_date) {
return $query->whereBetween('event_date', array("'".$fetch_date."'", "'".$fetch_date." 23:59:59'"->orderby('event_date', 'asc');
}
I'm trying to query to get all the events for a specific date. The $fetch_date is formatted appropriately and if I build the query directly into SQL like this it works:
SELECT * FROM events WHERE event_date BETWEEN '2016-07-12' AND '2016-07-12 23:59:49'
Any thoughts on the best way to get this accomplished?
Level 50
Please or to participate in this conversation.