From datetime 2018-12-12 10:10:10 to get only year-month I would usually do this in MySQL8.0
2018-12-12 10:10:10
date_format(\'2018-12-12 10:10:10\', \'%Y-%m\')