php - Selecting records that fall withing a time range in MySQL with Laravel 4 -


hello having problem cant figure out. have database couple of columns. title, body, start, , end.

the start , end columns of datetime type. have rows in database start , end dates.

i trying select rows fall within date range. in case 24 hour span.

so example, if have row has start day of today(sept. 24, 2013) , end date of jan. 1, 2014, expect returned.

route::get('/', function() { //start of day $start = date('y-m-d 00:00:00');  //end of day     $end = date('y-m-d 23:59:59');   $data['flyers'] = flyer::where('start', '>=', $start)->where('end', '<=', $end)->get();  //return homepage return view::make('view', $data); }); 

thanks in advance. post answer if figure out first.

the comparison operators on where() calls backwards. way code now, selecting flyers start , end today. want this:

$data['flyers'] = flyer::where('start', '<=', $start)->where('end', '>=', $end)->get(); 

Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -