Laravel where clause with date_format() example

Laravel where clause with date_format() example

In this post we will give you information about Laravel where clause with date_format() example. Hear we will give you detail about Laravel where clause with date_format() exampleAnd how to use it also give you demo for it if it is necessary.

In this post, i share with you that how to use date_format() with where condition of Laravel query builder. When i was working on my project, i require to search with get only selected month and year records from created_at(timestamp) column. I was thinking how can i but i know date_format() of mysql. but don’t know how to use in laravel where clause. At last i use DB::raw() of Laravel and it’s work.

If you have also need to search this way then you can do it this way:

Example:

$data = DB::table("items")

->select("id","title","created_at")

->where(DB::raw("(DATE_FORMAT(created_at,'%Y-%m'))"),"2016-07")

->get();

print_r($data);

Hope this code and post will helped you for implement Laravel where clause with date_format() example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

16  +    =  19

We accept paid advance and paid guest Posting on our Site : Contact US