How to get current year rows using MySql Query PHP?

Share Me
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Here Today now in this post i will show you How to get current year rows using MySql Query PHP? Sometimes we need to get the all records of current year by using mysql query. For an example we has one table as name “users” and the columns are id, name, phone_number, created_at and update_at, Now if we want to get the all records of this year. So we can easily fetch fields value by using DATE_SUB and INTERVAL of mysql. Now In following example i will show you how to select data of current year.

Example:

SELECT * FROM items WHERE created_at > DATE_SUB(NOW(), INTERVAL 1 YEAR);

Read Also: How to Mailchimp api integration in Laravel ?

Thanks for read. I hope it help you. For more you can follow us onĀ facebook

About code chef

My name is Shahriar sagor. I'm a developer. I live in Bangladesh and I love to write tutorials and tips that will help to other Developer's. I am a big fan of PHP, Javascript, JQuery, Laravel, Codeigniter, VueJS, AngularJS and Bootstrap from the early stage.

View all posts by code chef →