如何按日期查找以获取给定月份的记录

I have stored date like this format in db "2014-10-13" from this I need to show records only for the given month in Laravel.

Use mysql Month function

SELECT * FROM tbl_name WHERE MONTH( col_name ) = 3

In laravel:

$name = DB::table('tbl_name')->whereRaw('MONTH(col_name) = 3')->get();

Try this it will work :

SELECT * FROM table_name WHERE MONTH('2014-10-13') = '10';

larval :

$results = DB::select('select * from users where MONTH('2014-10-13') = ?', array(10));

Let me just assume the table names as users and assuming you are using eloquent since you have tagged it under laravel.

This is how you get the users who were created in a particular month.

Eloquent:

$month  = 12;// for december
$users = User::whereRaw('MONTH(created_at) = ?',[$month])->get();
return $users;

Query Builder:

$users = DB::table('users')->whereRaw('MONTH(created_at) = ?',[$month])->get();

if you also want to get the month in the results then

Eloquent:

$users = User::select(['*',DB::raw('MONTH(created_at) as month')])
                               ->whereRaw('MONTH(created_at) = ?',[$month])->get();

Query Builder:

$users = DB::table('users')->select(['*',DB::raw('MONTH(created_at) as month')])
                           ->whereRaw('MONTH(created_at) = ?',[$month])->get();