14 C
New York
Wednesday, November 30, 2022

How to get current month data in MySql PHP ?





If you require to get all the records of current month using mysql query. for example you have one table “items” and columns are id, title, description, created_at and update_at, Now you want to get all records of this month. so you can fetch fields value using DATE_SUB and INTERVAL of mysql. In following example you can see how to select data of current month.

Example:

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

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest Articles