Search code examples
phpmysqlsqlinnodb

get previous 12 month from sql


I have created Query which gets me the previous 12-month data which contain current month. I want the 12 months from the previous month. I don't get that, so can anyone help me over this.

create_data >= DATE_SUB(CURDATE(), INTERVAL 12 month) 

Solution

  • For the 12 months up to last month:

    create data between DATE_SUB(CURDATE(), INTERVAL 13 month)
                    and DATE_SUB(CURDATE(), INTERVAL 1 month)