Comparing different years in one graph from one data source

We do have grafana on premise an using an mysql database. Our solution to display multiple time series from the same data source but with i.e. the day before, we finally used something like:

SELECT
UNIX_TIMESTAMP(DATE_ADD( timeseries.ts, INTERVAL 1 DAY)) as time_sec,
timeseries.meassure as value,
CONCAT( metadata.name, " yesterday") as metric
FROM timeseries
INNER JOIN metadata
ON metadata.id = timeseries.id
WHERE
timeseries.ts >= DATE_SUB( $__timeFrom(), INTERVAL 1 DAY) AND timeseries.ts <= DATE_SUB( $__timeTo(), INTERVAL 1 DAY)
AND metadata.name = “Test”
ORDER BY timeseries.ts ASC

Basically we subtract the time shift from/to an add the same time frame to the ‘time_sec’ for Grafana. Therefore you will see both time series in one graph.
Hoperfully this will help someone!