86884/select-year-month-created-attributes-database-table-laravel
My problem is that I want to get data form the database table from the created_at attributes as per year and month only. The code I have tried is:
$post= Mjblog::select(DB::raw('YEAR(created_at) year, MONTH(created_at) month')); $posts_by_y_m = $post->where('created_at',$post)->get();
Hello @kartik,
There are date helpers available in the query builder:
$post = Mjblog::whereYear('created_at', '=', $year) ->whereMonth('created_at', '=', $month) ->get();
Hope it helps!!
Thank you!!
You need do little modification in your ...READ MORE
Hello, You have to use the package dotenv. Then ...READ MORE
Hello @kartik, The code below solved my problem: $messages ...READ MORE
Hello @kartik, There is a public getTable() method ...READ MORE
Hey @kartik, First you have to go to ...READ MORE
Named route is used to give specific ...READ MORE
Hello, This is simple you just need to ...READ MORE
Hey @kartik, Named routing is another amazing feature of ...READ MORE
You can get all columns name by ...READ MORE
Hii, Migrations are like version control for your database, ...READ MORE
OR
At least 1 upper-case and 1 lower-case letter
Minimum 8 characters and Maximum 50 characters
Already have an account? Sign in.