Previous month in sql I have sql, where I need to select data for this month and data for previous month. How to do extraction od previous month data? 

In my block in build() functionI have this:

//...
if ($what == "en_flip_per_month"){

    list($m, $y) = statistics_data_for_block('monthname', 'year');

    $sql = $connection-&gt;select('node_field_data', 'nfd');
    $sql-&gt;addExpression('COUNT(nfd.nid)', 'counting');
    $sql-&gt;where("nfd.langcode='en'");
    $sql-&gt;where("FROM_UNIXTIME(nfd.created, '%M' ) = ".$m."");
    $sql-&gt;where("FROM_UNIXTIME(nfd.created, '%Y' ) = ".$y."");
    $sql-&gt;groupBy('nfd.langcode');
    $sql-&gt;orderBy('nfd.created', 'DESC');
}
//....


and in my .module file I have this:

function statistics_data_for_block($m='', $y=''){
    $month = '';
    $year = '';

    //current
    if ($m == "month"){
        $month = "MONTH(CURRENT_TIMESTAMP)";
    }
    if ($m == "monthname"){
        $month = "MONTHNAME(CURRENT_TIMESTAMP)";
    }

    if ($y == 'year'){
        $year = "YEAR(CURRENT_TIMESTAMP)";
    }

    //... SOMETHING FOR PREVIOUS MONTH ...

    return array($month, $year);
}


So, I need a way to extract MONTH, MONTHNAME and YEAR of (CURRENT_TIMESTAMP - 1 month).

There was this one solution - use of SET and DECLARE, but how can it be done in Drupal 8 dynamic query?

Thanks
Not really related to Drupal, but this works on mySQL

MONTH(NOW() - INTERVAL 1 MONTH)
MONTHNAME(NOW() - INTERVAL 1 MONTH)
YEAR(NOW() - INTERVAL 1 MONTH)