Nurlan Nurlan - 5 months ago 21
MySQL Question

How do I get the first day of the current month?

I need to select data from MySQL database between the 1st day of the current month and current day.

select*from table_name
where date between "1st day of current month" and "current day"

Can someone provide working example of this query?

select * from table_name 
where (date between  DATE_ADD(LAST_DAY(DATE_SUB(CURDATE(), interval 30 day), interval 1 day) AND CURDATE() )

Or better :

select * from table_name 
where (date between  DATE_FORMAT(NOW() ,'%Y-%m-01') AND NOW() )