Q:

Need to create a query for monthly data

I need to create a query in mysql  to retrieve data where  CREATED_DATE range should be 20th of current month to 20th of previous month. Please suggest..thanks

A:

You can get dynamic records using current month, by the following query
SELECT * FROM table_name WHERE CREATED_DATE BETWEEN 
DATE_FORMAT(NOW(),'%Y-%m-20') - INTERVAL 1 MONTH 
AND DATE_FORMAT( NOW(),'%Y-%m-20')

Check the live result at the fiddle http://sqlfiddle.com/#!2/4668c/7

