const year = new Date().getFullYear()
const query = `SELECT SUM(CONSO) FROM TEMPO WHERE DATE >= '${year}-01-01' AND DATE<= '${year}-12-31';`
msg.query = query
return msg
A possible alternative approach retrieving multiple years' costs.
Also because it's Mariadb, using msg.topic not msg.query
NB It might need an ORDER BY DATE clause too.
msg.topic = "SELECT Year(DATE) AS YEAR, SUM(CONSO) AS TOTAL FROM TEMPO GROUP BY Year(DATE)"
return msg;