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.
SELECT * FROM items WHERE created_at > DATE_SUB(NOW(), INTERVAL 1 YEAR);
Thanks for read. I hope it help you. For more you can follow us on facebook