How do I select between the 1st day of the current month and current day in MySQL?

Nurlan picture Nurlan · Aug 4, 2012 · Viewed 107.8k times · Source

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?

Answer

aleroot picture aleroot · Aug 4, 2012
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() )