I have a DateTime field in my index GridView and would like to have a filter that only filters based on the date solely. So, display all the entries for that selected date regardless of the time part of the DateTime entry, how can I do this? I’m assuming this is a question of altering the Search model, just not sure how. Adding a date picker to the index isn’t an issue as I have that part sorted out.
In my current Search model I have
'Start' => $this->Start,
Solved. For anyone else trying to figure it out, this is what worked for me.
I commented out the original filter and then added this below
if( $this->Start ){
$query->andFilterWhere(['between', 'Start', $this->Start.' 00:00:00', $this->Start.' 23:59:59']);
}
The if() is critical or else when no filter is applied you get no records returned.
You could technically do the following, but it is not a good idea from a performance standpoint (much better with the solution provided above)
$query->andFilterWhere(['=', 'Date_Format(Start, "%Y-%m-%d")', $this->Start])